From 09258e8a0107ade9f7b37f8816ee8da1d8db50de Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 29 Oct 2021 15:48:12 +1300 Subject: [PATCH 01/38] initial code --- .../meshtype_3d_solidbifurcation1.py | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py new file mode 100644 index 00000000..9e3628a6 --- /dev/null +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py @@ -0,0 +1,194 @@ +""" +Generates a solid cylinder using a ShieldMesh of all cube elements, + with variable numbers of elements in major, minor, shell and axial directions. +""" + +from __future__ import division +import math +import copy +from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates +from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base +from scaffoldmaker.utils.meshrefinement import MeshRefinement +from scaffoldmaker.utils.cylindermesh import CylinderMesh, CylinderShape, CylinderEnds, CylinderCentralPath +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from opencmiss.zinc.node import Node + + +class MeshType_3d_solidbifurcation1(Scaffold_base): + """ +Generates a solid cylinder using a ShieldMesh of all cube elements, +with variable numbers of elements in major, minor, shell and axial directions. + """ + centralPathDefaultScaffoldPackages = { + 'Cylinder 1': ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 3.0, + 'Number of elements': 3 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + [[0.0, 0.0, 2.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] + ]) + }) + } + + @staticmethod + def getName(): + return '3D Solid Bifurcation 1' + + @classmethod + def getDefaultOptions(cls, parameterSetName='Default'): + centralPathOption = cls.centralPathDefaultScaffoldPackages['Cylinder 1'] + options = { + 'Central path': copy.deepcopy(centralPathOption), + 'Number of elements across major': 4, + 'Number of elements across minor': 4, + 'Number of elements across shell': 0, + 'Number of elements across transition': 1, + 'Number of elements along': 1, + 'Shell element thickness proportion': 1.0, + 'Lower half': False, + 'Use cross derivatives': False, + 'Refine': False, + 'Refine number of elements across major': 1, + 'Refine number of elements along': 1 + } + return options + + @staticmethod + def getOrderedOptionNames(): + return [ + 'Central path', + 'Number of elements across major', + 'Number of elements across minor', + 'Number of elements across shell', + 'Number of elements across transition', + 'Number of elements along', + 'Shell element thickness proportion', + 'Lower half', + 'Refine', + 'Refine number of elements across major', + 'Refine number of elements along' + ] + + @classmethod + def getOptionValidScaffoldTypes(cls, optionName): + if optionName == 'Central path': + return [MeshType_1d_path1] + return [] + + @classmethod + def getOptionScaffoldTypeParameterSetNames(cls, optionName, scaffoldType): + if optionName == 'Central path': + return list(cls.centralPathDefaultScaffoldPackages.keys()) + assert scaffoldType in cls.getOptionValidScaffoldTypes(optionName), \ + cls.__name__ + '.getOptionScaffoldTypeParameterSetNames. ' + \ + 'Invalid option \'' + optionName + '\' scaffold type ' + scaffoldType.getName() + return scaffoldType.getParameterSetNames() + + @classmethod + def getOptionScaffoldPackage(cls, optionName, scaffoldType, parameterSetName=None): + ''' + :param parameterSetName: Name of valid parameter set for option Scaffold, or None for default. + :return: ScaffoldPackage. + ''' + if parameterSetName: + assert parameterSetName in cls.getOptionScaffoldTypeParameterSetNames(optionName, scaffoldType), \ + 'Invalid parameter set ' + str(parameterSetName) + ' for scaffold ' + str(scaffoldType.getName()) + \ + ' in option ' + str(optionName) + ' of scaffold ' + cls.getName() + if optionName == 'Central path': + if not parameterSetName: + parameterSetName = list(cls.centralPathDefaultScaffoldPackages.keys())[0] + return copy.deepcopy(cls.centralPathDefaultScaffoldPackages[parameterSetName]) + assert False, cls.__name__ + '.getOptionScaffoldPackage: Option ' + optionName + ' is not a scaffold' + + @classmethod + def checkOptions(cls, options): + if not options['Central path'].getScaffoldType() in cls.getOptionValidScaffoldTypes('Central path'): + options['Central path'] = cls.getOptionScaffoldPackage('Central path', MeshType_1d_path1) + dependentChanges = False + + if options['Number of elements across major'] < 4: + options['Number of elements across major'] = 4 + if options['Number of elements across major'] % 2: + options['Number of elements across major'] += 1 + + if options['Number of elements across minor'] < 4: + options['Number of elements across minor'] = 4 + if options['Number of elements across minor'] % 2: + options['Number of elements across minor'] += 1 + if options['Number of elements along'] < 1: + options['Number of elements along'] = 1 + if options['Number of elements across transition'] < 1: + options['Number of elements across transition'] = 1 + Rcrit = min(options['Number of elements across major']-4, options['Number of elements across minor']-4)//2 + if options['Number of elements across shell'] + options['Number of elements across transition'] - 1 > Rcrit: + dependentChanges = True + options['Number of elements across shell'] = Rcrit + options['Number of elements across transition'] = 1 + + if options['Shell element thickness proportion'] < 0.15: + options['Shell element thickness proportion'] = 1.0 + + return dependentChanges + + @staticmethod + def generateBaseMesh(region, options): + """ + Generate the base tricubic Hermite mesh. See also generateMesh(). + :param region: Zinc region to define model in. Must be empty. + :param options: Dict containing options. See getDefaultOptions(). + :return: None + """ + + 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'] + elementsCountAlong = options['Number of elements along'] + shellProportion = options['Shell element thickness proportion'] + useCrossDerivatives = options['Use cross derivatives'] + + fm = region.getFieldmodule() + coordinates = findOrCreateFieldCoordinates(fm) + + cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF + + base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, + elementsCountAcrossTransition, + shellProportion, + [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + + annotationGroup = [] + return annotationGroup + + @classmethod + def refineMesh(cls, meshRefinement, options): + """ + Refine source mesh into separate region, with change of basis. + :param meshRefinement: MeshRefinement, which knows source and target region. + :param options: Dict containing options. See getDefaultOptions(). + """ + assert isinstance(meshRefinement, MeshRefinement) + refineElementsCountAcrossMajor = options['Refine number of elements across major'] + refineElementsCountAlong = options['Refine number of elements along'] + meshRefinement.refineAllElementsCubeStandard3d(refineElementsCountAcrossMajor, refineElementsCountAlong, refineElementsCountAcrossMajor) From 7edf4be7f9abdfdbf3b5db0ced89895a424dd1b3 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 29 Oct 2021 15:48:12 +1300 Subject: [PATCH 02/38] initial code --- src/scaffoldmaker/scaffolds.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/scaffoldmaker/scaffolds.py b/src/scaffoldmaker/scaffolds.py index ccee1115..2de62b26 100644 --- a/src/scaffoldmaker/scaffolds.py +++ b/src/scaffoldmaker/scaffolds.py @@ -37,9 +37,15 @@ from scaffoldmaker.meshtypes.meshtype_3d_musclefusiform1 import MeshType_3d_musclefusiform1 from scaffoldmaker.meshtypes.meshtype_3d_ostium1 import MeshType_3d_ostium1 from scaffoldmaker.meshtypes.meshtype_3d_smallintestine1 import MeshType_3d_smallintestine1 +<<<<<<< HEAD from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere2 import MeshType_3d_solidsphere2 +======= +from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation1 import MeshType_3d_solidbifurcation1 +from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 +from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 +>>>>>>> ef3433d (initial code) from scaffoldmaker.meshtypes.meshtype_3d_sphereshell1 import MeshType_3d_sphereshell1 from scaffoldmaker.meshtypes.meshtype_3d_sphereshellseptum1 import MeshType_3d_sphereshellseptum1 from scaffoldmaker.meshtypes.meshtype_3d_stellate1 import MeshType_3d_stellate1 @@ -89,9 +95,15 @@ def __init__(self): MeshType_3d_musclefusiform1, MeshType_3d_ostium1, MeshType_3d_smallintestine1, +<<<<<<< HEAD MeshType_3d_solidcylinder1, MeshType_3d_solidsphere1, MeshType_3d_solidsphere2, +======= + MeshType_3d_solidbifurcation1, + MeshType_3d_solidcylinder1, + MeshType_3d_solidsphere1, +>>>>>>> ef3433d (initial code) MeshType_3d_sphereshell1, MeshType_3d_sphereshellseptum1, MeshType_3d_stellate1, From 9cb9a31d7079ba19769de22671512550c1053358 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 5 Nov 2021 11:27:43 +1300 Subject: [PATCH 03/38] half of the right armpit --- .../meshtype_3d_solidbifurcation1.py | 26 +- src/scaffoldmaker/utils/bifurcation3d.py | 706 ++++++++++++++++++ src/scaffoldmaker/utils/cylindermesh.py | 3 + 3 files changed, 723 insertions(+), 12 deletions(-) create mode 100644 src/scaffoldmaker/utils/bifurcation3d.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py index 9e3628a6..15f257bc 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py @@ -14,6 +14,7 @@ from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 from opencmiss.zinc.node import Node +from scaffoldmaker.utils.bifurcation3d import BifurcationMesh class MeshType_3d_solidbifurcation1(Scaffold_base): @@ -165,18 +166,19 @@ def generateBaseMesh(region, options): fm = region.getFieldmodule() coordinates = findOrCreateFieldCoordinates(fm) - cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF - - base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, - elementsCountAcrossTransition, - shellProportion, - [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + # cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) + # + # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF + # + # base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, + # elementsCountAcrossTransition, + # shellProportion, + # [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + # cylinderCentralPath.minorRadii[0]) + # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, + # cylinderShape=cylinderShape, + # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + bifurcation1 = BifurcationMesh(fm, coordinates) annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py new file mode 100644 index 00000000..dca1b1f9 --- /dev/null +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -0,0 +1,706 @@ +""" +Utility functions for generating a 3-D solid bifurcation. +""" + +from enum import Enum +from scaffoldmaker.utils import vector, geometry +import math +from opencmiss.zinc.field import Field +from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier +from scaffoldmaker.utils.shieldmesh import ShieldMesh, ShieldShape, ShieldRimDerivativeMode +from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ + smoothCubicHermiteDerivativesLine, interpolateSampleLinear +from opencmiss.zinc.node import Node +from scaffoldmaker.utils.mirror import Mirror +from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape +from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite +from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds +from opencmiss.zinc.element import Element + + +class BifurcationMesh: + """ + Bifurction mesh generator. + """ + + def __init__(self, fieldModule, coordinates): + """ + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + """ + # generate the mesh + elementsCount = [2, 2, 5] + self._elementsCount = elementsCount + + self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.createBifurcationMesh3d(fieldModule, coordinates) + + def createBifurcationMesh3d(self, fieldmodule, coordinates): + """ + Create a bifurcation. + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + :return: Final values of nextNodeIdentifier, nextElementIdentifier. + """ + # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + nodeparams1 = [[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]], + [[0.0, 1/self._elementsCount[1], 0.0], [0.0, 1/self._elementsCount[1], 0.0]]], + [[0.0, 0.0, 1.4], [1.2, 0.0, 1.0], [0.0, 1.0, 1.4], [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]], + [[0.0, 1/self._elementsCount[1], 0.0], [0.0, 1/self._elementsCount[1], 0.0]]]] + + nodeparams2 = [[[0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]], + [[1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], + [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]]] + + baseleg1 = BaseLeg(self._elementsCount, nodeparams1) + self.copyBaseLeg2Bifurcation(baseleg1, 1) + + self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] + self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] + self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] + self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + + baseleg2 = BaseLeg(self._elementsCount, nodeparams2) + self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + self.generateNodes(nodes, fieldmodule, coordinates) + self.generateElements(mesh, fieldmodule, coordinates) + + + + elementsCount = [2, 2, 5] + self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], + [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] + + nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], + [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], + [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], + [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] + + + baseleg1 = BaseLeg(self._elementsCount, nodeparams1) + self.copyBaseLeg2Bifurcation(baseleg1, 1) + + # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] + # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] + # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] + # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + + baseleg2 = BaseLeg(self._elementsCount, nodeparams2) + self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + def copyBaseLeg2Bifurcation(self, baseleg, idx): + """ + + :return: + """ + for n3 in range(self._elementsCount[2]//2 + 1): + for n2 in range(self._elementsCount[0] + 1): + for n1 in range(self._elementsCount[1] + 1): + if idx == 1: + n3s = n3 + elif idx == 2: + n3s = self._elementsCount[2]//2 + 1 + n3 + self.px[n3s][n2][n1] = baseleg.px[n3][n2][n1] + self.pd1[n3s][n2][n1] = baseleg.pd1[n3][n2][n1] + self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] + self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] + if idx == 2 and n3 == 0: + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): + self.px[n3s][n2][n1] = None + self.pd1[n3s][n2][n1] = None + self.pd2[n3s][n2][n1] = None + self.pd3[n3s][n2][n1] = None + + def generateNodes(self, nodes, fieldModule, coordinates): + """ + Create cylinder nodes from coordinates. + :param nodes: nodes from coordinates. + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + self._startNodeIdentifier = nodeIdentifier + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier) + self._endNodeIdentifier = nodeIdentifier + + def generateElements(self, mesh, fieldModule, coordinates): + """ + Create cylinder elements from nodes. + :param mesh: + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + self._startElementIdentifier = elementIdentifier + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, []) + self._endElementIdentifier = elementIdentifier + + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier): + """ + Create shield nodes from coordinates. + """ + nodeIdentifier = startNodeIdentifier + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) + cache = fieldmodule.createFieldcache() + + for n3 in range(self._elementsCount[2] + 1): + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 2): + if self.px[n3][n2][n1]: + node = nodes.createNode(nodeIdentifier, nodetemplate) + self.nodeId[n3][n2][n1] = nodeIdentifier + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, self.px [n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, self.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, self.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, self.pd3[n3][n2][n1]) + nodeIdentifier += 1 + + return nodeIdentifier + + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, 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 meshGroups: Zinc mesh groups to add elements to. + :return: next elementIdentifier. + """ + elementIdentifier = startElementIdentifier + useCrossDerivatives = False + mesh = fieldmodule.findMeshByDimension(3) + + tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) + eft = tricubichermite.createEftNoCrossDerivatives() + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) + elementtemplate.defineField(coordinates, -1, eft) + + elementtemplate1 = mesh.createElementtemplate() + elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) + + # isEven = (self.elementsCountAcross % 2) == 0 + e1a = 0 + e1b = e1a + 1 + e1z = 2*self._elementsCount[0] - 1 + e1y = e1z - 1 + e2a = 0 + e2b = e2a + 1 + e2c = e2a + 2 + e2z = 2*self._elementsCount[1]-1 + e2y = e2z - 1 + # e2x = e2z - 2 + for e3 in range(self._elementsCount[2]): + for e2 in range(self._elementsCount[1]): + for e1 in range(self._elementsCount[0]+1): + eft1 = eft + scalefactors = None + nids = [ self.nodeId[e3][e2][e1], self.nodeId[e3][e2 + 1][e1], self.nodeId[e3+1][e2][e1], self.nodeId[e3+1][e2 + 1][e1], + self.nodeId[e3][e2][e1 + 1], self.nodeId[e3][e2 + 1][e1 + 1], self.nodeId[e3+1][e2][e1 + 1], self.nodeId[e3+1][e2 + 1][e1 + 1] ] + + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [self.nodeId[e3][e2+1][e1], self.nodeId[e3][e2+1][e1+1], self.nodeId[e3+1][e2+1][e1], self.nodeId[e3+1][e2+1][e1+1], + self.nodeId[e3][e2][e1], self.nodeId[e3][e2][e1+1], self.nodeId[e3+1][e2][e1], self.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [self.nodeId[e3][e2][e1+1], self.nodeId[e3][e2][e1], self.nodeId[e3+1][e2][e1+1], self.nodeId[e3+1][e2][e1], + self.nodeId[e3][e2+1][e1+1], self.nodeId[e3][e2+1][e1], self.nodeId[e3+1][e2+1][e1+1], self.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e3 == self._elementsCount[2] // 2 + 1 and e1 == e1b: + e3r = e3-1 + nids[0] = self.nodeId[e3r][e2][e1] + nids[1] = self.nodeId[e3r][e2 + 1][e1] + + if e3 == 2: + remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + elif e3 == 3: + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + + else: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + if e3 != 2: + remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + else: + remapEftNodeValueLabel(eft1, [ 6, 8 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [self.nodeId[e3][e2c][e1+1], self.nodeId[e3][e2r+1][e1b], self.nodeId[e3+1][e2c][e1+1], self.nodeId[e3+1][e2r+1][e1b], + self.nodeId[e3][e2c][e1], self.nodeId[e3][e2r][e1b], self.nodeId[e3+1][e2c][e1], self.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*self._elementsCount[1] - e1-1 + nids = [self.nodeId[e3][e2r][e1b], self.nodeId[e3][e2y][e1+1], self.nodeId[e3+1][e2r][e1b], self.nodeId[e3+1][e2y][e1+1], + self.nodeId[e3][e2r+1][e1b], self.nodeId[e3][e2y][e1], self.nodeId[e3+1][e2r+1][e1b], self.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == self._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = self.nodeId[e3r][e2a][e1b] + nids[2] = self.nodeId[e3+1][e2a][e1b] + nids[1] = self.nodeId[e3r][e2 + 1][e1] + nids[4] = self.nodeId[e3r][e2][e1 + 1] + nids[5] = self.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = self.nodeId[e3][e2a][e1b] + nids[2] = self.nodeId[e3+1][e2a][e1b] + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = self.nodeId[e3][e2z+1][e1b] + nids[3] = self.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + 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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + 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] + nids[7] = self.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e1 > e1z: + e2r = self._elementsCount[0] - e1 + if e2 == e2b: + nids = [self.nodeId[e3][e2r][e1z], self.nodeId[e3][e2c][e1], self.nodeId[e3+1][e2r][e1z], self.nodeId[e3+1][e2c][e1], + self.nodeId[e3][e2r-1][e1z], self.nodeId[e3][e2c][e1+1], self.nodeId[e3+1][e2r-1][e1z], self.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = self.nodeId[e3][e2r][e1z] + nids[3] = self.nodeId[e3+1][e2r][e1z] + nids[5] = self.nodeId[e3][e2r+1][e1z] + nids[7] = self.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == self._elementsCount[2] // 2 + 1: + e3r = e3 - 1 + nids[0] = self.nodeId[e3r][e2][e1] + nids[1] = self.nodeId[e3r][e2 + 1][e1] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + if e3 == 2: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + + + + + + else: + if e1 < e1a: + nids = [ self.nodeId[e3][e2 + 1][e1 + 1], self.nodeId[e3][e2][e1 + 1], self.nodeId[e3+1][e2 + 1][e1 + 1], self.nodeId[e3+1][e2][e1 + 1], + self.nodeId[e3][e2 + 1][e1], self.nodeId[e3][e2][e1], self.nodeId[e3+1][e2 + 1][e1], self.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) + + if e3 == 2: + if e1 == e1b: + # joining elements + if e2 == 0: + nids = [15, 17, 22, 24, 16, 18, 23, 25] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + + + + + elif e2 == 1: + nids = [17, 20, 24, 26, 18, 21, 25, 27] + + if not all(nids): + continue + + if eft1 is not eft: + elementtemplate1.defineField(coordinates, -1, eft1) + element = mesh.createElement(elementIdentifier, elementtemplate1) + else: + element = mesh.createElement(elementIdentifier, elementtemplate) + result2 = element.setNodesByIdentifier(eft1, nids) + if scalefactors: + result3 = element.setScaleFactors(eft1, scalefactors) + else: + result3 = 7 + #print('create element shield', elementIdentifier, result2, result3, nids) + self.elementId[e3][e2][e1] = elementIdentifier + elementIdentifier += 1 + + for meshGroup in meshGroups: + meshGroup.addElement(element) + + return elementIdentifier + + +class BaseLeg: + """ + Base case for creating a child + """ + def __init__(self, elementsCount, nodeparams): + """ + + :param fieldmodule: + :param coordinates: + :param mesh: + :param nodes: + """ + elementsCount = [2, 2, 2] + self._elementsCount = elementsCount + self.nodeparams = nodeparams + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.generateBaseLeg(nodeparams) + + def generateBaseLeg(self, nodeparams): + """ + Generate base leg that is a cylinder generated from cylinder ends. + :return: + """ + bottomnodeparams = nodeparams[0] + topnodeparams = nodeparams[1] + self.genetateBottomSurface(bottomnodeparams) + self.generateTopSurface(topnodeparams) + self.generateMiddleLevels() + self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateMiddleLevels() + # self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + def genetateBottomSurface(self, bottomnodeparams): + """ + Use major and minor curves to generate the ellipse + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, 0) + + def generateTopSurface(self, topnodeparams): + """ + + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + + def generateMiddleLevels(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # generate the armpit curves. + elementsCountOut = 2 + txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], + btx[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [btd2[0][self._elementsCount[1]][self._elementsCount[0]], + btd2[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + elementsCountOut) + txec1, td1ec1, pec1, pxic1, psfc1 = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][0], btx[self._elementsCount[2]][self._elementsCount[1]][0]], + [btd2[0][self._elementsCount[1]][0], btd2[self._elementsCount[2]][self._elementsCount[1]][0]], + elementsCountOut) + txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]], btx[self._elementsCount[2]][0][self._elementsCount[0]]], + [btd2[0][0][self._elementsCount[0]], btd2[self._elementsCount[2]][0][self._elementsCount[0]]], + elementsCountOut) + + tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][self._elementsCount[0]], + btd3[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]][self._elementsCount[0]], + btd1[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlec1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][0], + btd3[self._elementsCount[2]][self._elementsCount[1]][0]], + [[0.0, 0.0, 0.0]] * 2, pec1, pxic1, psfc1)[0] + tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]], + btd3[self._elementsCount[2]][0][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] + + for n3 in range(1, self._elementsCount[2]): + centre = txcc1[n3] + txc1, td1c1 = self.generate1DPath([centre, txec1[n3]], [[-c for c in tdlcc1[n3]], tdlec1[n3]], self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, n3) + + def smoothd2(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # smooth d2 + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + nx = [] + nd1 = [] + for n3 in range(self._elementsCount[2] + 1): + nx.append(btx[n3][n2][n1]) + nd1.append(btd2[n3][n2][n1]) + td2 = smoothCubicHermiteDerivativesLine(nx, nd1) + for n3 in range(self._elementsCount[2] + 1): + btd2[n3][n2][n1] = td2[n3] + + def generate1DPath(self, nx, nd1, elementsCountOut): + """ + Given end nodes generate 1d path + :return: + """ + tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) + return tx, td1 + + def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): + """ + Get major and minor curves to generate the rounded surface. + :return: + """ + + # self._coreMinorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) + # self._coreMajorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) + + # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 + # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] + # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] + majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] + minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] + elementsCountAcrossShell = 0 + elementsCountAcrossTransition = 1 + shellProportion = 1.0 + coreMajorRadius = 1.0 + coreMinorRadius = 1.0 + elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 + ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + shield = ellipse.getShield() + ellipse.generateBase1DMesh(0) + + ellipse.px[self._elementsCount[1]][0] = txc1[-1] + ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] + ellipse.px[0][self._elementsCount[0]] = txc2[-1] + ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] + + nx = [] + nd1 = [] + for n in range(elementsCountAround + 1): + n1, n2 = shield.convertRimIndex(n) + xi = n/elementsCountAround + # ellipse.px[n2][n1][2] = (1 - xi) * ellipse.px[self._elementsCount[1]][0][2] + xi * \ + # ellipse.px[0][self._elementsCount[0]][2] + delta = [ellipse.px[0][self._elementsCount[0]][c] - ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) + delnormag = vector.dotproduct(delta, normal) + delnor = [delnormag*c for c in normal] + if 0>>>>>> 33b365c (half of the right armpit) def getShield(self): return self.__shield From 1d7dd859e012f83ea03bf97a9df9e3f92a55ccec Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Wed, 10 Nov 2021 14:53:22 +1300 Subject: [PATCH 04/38] Changing topology --- src/scaffoldmaker/utils/bifurcation3d.py | 136 +++++++++++++---------- 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index dca1b1f9..7aaa08be 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -33,11 +33,18 @@ def __init__(self, fieldModule, coordinates): elementsCount = [2, 2, 5] self._elementsCount = elementsCount - self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] + self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] self.createBifurcationMesh3d(fieldModule, coordinates) @@ -72,18 +79,18 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): baseleg1 = BaseLeg(self._elementsCount, nodeparams1) self.copyBaseLeg2Bifurcation(baseleg1, 1) - self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] - self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] - self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] - self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, 1.0, 2.2] + self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, 0.5, 2.2] + self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, 0.0, 2.2] + self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, -0.5, 0.0] + self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, -0.5, 0.0] + self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, -0.5, 0.0] + self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.5, 0.0, 0.0] + self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.5, 0.0, 0.0] + self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.5, 0.0, 0.0] + self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, 0.0, 0.7] + self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, 0.0, 0.7] + self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, 0.0, 0.7] baseleg2 = BaseLeg(self._elementsCount, nodeparams2) self.copyBaseLeg2Bifurcation(baseleg2, 2) @@ -94,43 +101,43 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): - elementsCount = [2, 2, 5] - self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], - [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] - - nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], - [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], - [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], - [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] - - - baseleg1 = BaseLeg(self._elementsCount, nodeparams1) - self.copyBaseLeg2Bifurcation(baseleg1, 1) - - # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] - # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] - # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] - # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - - baseleg2 = BaseLeg(self._elementsCount, nodeparams2) - self.copyBaseLeg2Bifurcation(baseleg2, 2) + # elementsCount = [2, 2, 5] + # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] + # + # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], + # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] + # + # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], + # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] + # + # + # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + # + # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] + # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] + # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] + # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # + # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) + # self.copyBaseLeg2Bifurcation(baseleg2, 2) # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) # self.generateNodes(nodes, fieldmodule, coordinates) @@ -147,7 +154,7 @@ def copyBaseLeg2Bifurcation(self, baseleg, idx): if idx == 1: n3s = n3 elif idx == 2: - n3s = self._elementsCount[2]//2 + 1 + n3 + n3s = self._elementsCount[2]//2 + 2 + n3 self.px[n3s][n2][n1] = baseleg.px[n3][n2][n1] self.pd1[n3s][n2][n1] = baseleg.pd1[n3][n2][n1] self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] @@ -198,9 +205,9 @@ def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier): nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) cache = fieldmodule.createFieldcache() - for n3 in range(self._elementsCount[2] + 1): + for n3 in range(self._elementsCount[2] + 2): for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 2): + for n1 in range(self._elementsCount[0] + 1): if self.px[n3][n2][n1]: node = nodes.createNode(nodeIdentifier, nodetemplate) self.nodeId[n3][n2][n1] = nodeIdentifier @@ -248,11 +255,15 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # e2x = e2z - 2 for e3 in range(self._elementsCount[2]): for e2 in range(self._elementsCount[1]): - for e1 in range(self._elementsCount[0]+1): + for e1 in range(self._elementsCount[0]): eft1 = eft scalefactors = None - nids = [ self.nodeId[e3][e2][e1], self.nodeId[e3][e2 + 1][e1], self.nodeId[e3+1][e2][e1], self.nodeId[e3+1][e2 + 1][e1], - self.nodeId[e3][e2][e1 + 1], self.nodeId[e3][e2 + 1][e1 + 1], self.nodeId[e3+1][e2][e1 + 1], self.nodeId[e3+1][e2 + 1][e1 + 1] ] + if e3 >= 3: + e3t = e3 + 1 + else: + e3t = e3 + nids = [ self.nodeId[e3t][e2][e1], self.nodeId[e3t][e2 + 1][e1], self.nodeId[e3t+1][e2][e1], self.nodeId[e3t+1][e2 + 1][e1], + self.nodeId[e3t][e2][e1 + 1], self.nodeId[e3t][e2 + 1][e1 + 1], self.nodeId[e3t+1][e2][e1 + 1], self.nodeId[e3t+1][e2 + 1][e1 + 1] ] if (e2 < e2b) or (e2 > e2y): if (e1 < e1b) or (e1 > e1y): @@ -271,7 +282,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] if e3 == self._elementsCount[2] // 2 + 1 and e1 == e1b: - e3r = e3-1 + e3r = e3t-1 nids[0] = self.nodeId[e3r][e2][e1] nids[1] = self.nodeId[e3r][e2 + 1][e1] @@ -441,6 +452,9 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e2 == 1: nids = [17, 20, 24, 26, 18, 21, 25, 27] + print(e3, e2, e1) + print(nids) + if not all(nids): continue From e1cd011234cdd5bd5d56f75c7f73c5afb6baef7f Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 15 Nov 2021 09:27:46 +1300 Subject: [PATCH 05/38] Minor changes --- src/scaffoldmaker/utils/bifurcation3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index 7aaa08be..2a70d1a1 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -7,7 +7,7 @@ import math from opencmiss.zinc.field import Field from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier -from scaffoldmaker.utils.shieldmesh import ShieldMesh, ShieldShape, ShieldRimDerivativeMode +from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ smoothCubicHermiteDerivativesLine, interpolateSampleLinear from opencmiss.zinc.node import Node From 13c6d382a3052fa82616c27c0cab7fdaf4616224 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 6 Dec 2021 16:41:19 +1300 Subject: [PATCH 06/38] Update annotation terms for the stomach --- src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py index a837f012..e32f7400 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py @@ -406,7 +406,11 @@ def generateBaseMesh(region, options): 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('esophagogastric junction along the lesser curvature on serosa') +<<<<<<< HEAD limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge at the greater curvature on serosa') +======= + limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge along the greater curvature on serosa') +>>>>>>> cd0dea4 (Update annotation terms for the stomach) 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') From 231b6e95476f8bef48490be2a8f0109a93fc8547 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 14 Dec 2021 12:30:00 +1300 Subject: [PATCH 07/38] lower limbs and torso --- .../meshtype_3d_solidbifurcation1.py | 2 +- src/scaffoldmaker/utils/bifurcation3d.py | 844 +++++++++++++----- src/scaffoldmaker/utils/geometry.py | 16 + 3 files changed, 619 insertions(+), 243 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py index 15f257bc..c63c5e3d 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py @@ -178,7 +178,7 @@ def generateBaseMesh(region, options): # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, # cylinderShape=cylinderShape, # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - bifurcation1 = BifurcationMesh(fm, coordinates) + bifurcation1 = BifurcationMesh(fm, coordinates, region) annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index 2a70d1a1..e5eb082d 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -1,7 +1,7 @@ """ Utility functions for generating a 3-D solid bifurcation. """ - +import copy from enum import Enum from scaffoldmaker.utils import vector, geometry import math @@ -13,10 +13,13 @@ from opencmiss.zinc.node import Node from scaffoldmaker.utils.mirror import Mirror from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion -from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds from opencmiss.zinc.element import Element +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues class BifurcationMesh: @@ -24,7 +27,7 @@ class BifurcationMesh: Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates): + def __init__(self, fieldModule, coordinates, region): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -32,20 +35,8 @@ def __init__(self, fieldModule, coordinates): # generate the mesh elementsCount = [2, 2, 5] self._elementsCount = elementsCount + self._region = region - # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 2)] - - self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] self.createBifurcationMesh3d(fieldModule, coordinates) def createBifurcationMesh3d(self, fieldmodule, coordinates): @@ -76,28 +67,136 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): [[1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]]] - baseleg1 = BaseLeg(self._elementsCount, nodeparams1) - self.copyBaseLeg2Bifurcation(baseleg1, 1) - - self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, 1.0, 2.2] - self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, 0.5, 2.2] - self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, 0.0, 2.2] - self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, -0.5, 0.0] - self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, -0.5, 0.0] - self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, -0.5, 0.0] - self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.5, 0.0, 0.0] - self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.5, 0.0, 0.0] - self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.5, 0.0, 0.0] - self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0]] = [0.0, 0.0, 0.7] - self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0]] = [0.0, 0.0, 0.7] - self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0]] = [0.0, 0.0, 0.7] - - baseleg2 = BaseLeg(self._elementsCount, nodeparams2) - self.copyBaseLeg2Bifurcation(baseleg2, 2) + bottom_part = BaseLeg(self._elementsCount, nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + + shoulder_part = BaseLeg(self._elementsCount, nodeparams2) + shoulder_part._shoulder = True + # self.copyBaseLeg2Bifurcation(baseleg2, 2) # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - self.generateNodes(nodes, fieldmodule, coordinates) - self.generateElements(mesh, fieldmodule, coordinates) + self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, bottom_part) + + self.remove_duplicate_nodes_from_shoulder(shoulder_part) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + + joining_box = JoiningBox([1, 4, 1]) + self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + self.generateElements(mesh, fieldmodule, coordinates, joining_box) + + shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) + self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) + + bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) + self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) + self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) + self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) + + centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] + outer_point = [4.417e-01, 4.174e-02, 3.897e+00] + + p1 = [-1.12e+00, 9.29e-02, 3.22e+00] + p2 = [-1.62e+00, 1.061e-01, 3.72e+00] + p3 = [-2.12e+00, 1.14e-01, 4.26e+00] + p4 = [-2.605e+00, 1.22e-01, 4.76e+00] + d11 = vector.addVectors([p1, centre], [1, -1]) + d21 = vector.addVectors([outer_point, centre], [1, -1]) + d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) + + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 3.0, + 'Number of elements': 4 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] + ]) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(4, 4, 0, 1, 1.0, + centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + + joining_torso = JoiningTorso([4, 4, 1]) + self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) + print(joining_torso.nodeId) + self.generateElements(mesh, fieldmodule, coordinates, joining_torso) + + + torso_part = torso_cylinder._shield + + +# -4.990e+00, -7.830e-01, 5.4884e+00 +# +# +# +# -6.480e+00, 1.118e-01, 3.8448e+00 +# +# -4.947e+00, 1.216e-01, 5.4829e+00 +# +# -6.004e+00, -6.005e-01, 3.3709e+00 +#-6.031e+00, 9.325e-02, 3.393e+00 + +# -6.496e+00, -5.925e-01, 3.8599e+00 + + # -6.031e+00, 9.325e-02, 3.393e+00 + + nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], + [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], + [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], + [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] + + bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) + + self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) + self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) + + # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], + # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], + # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], + # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] + + nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], + [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], + [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], + [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] + + shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) + shoulder_part2._shoulder = True + + self.remove_duplicate_nodes_from_shoulder(shoulder_part2) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) + self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) + # + # joining_box = JoiningBox([1, 4, 1]) + # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box) + @@ -143,6 +242,118 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # self.generateNodes(nodes, fieldmodule, coordinates) # self.generateElements(mesh, fieldmodule, coordinates) + def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): + """ + + :param joining_torso: + :param shoulder_part: + :param bottom_part: + :return: + """ + for n2 in range(joining_torso._elementsCount[1] + 1): + for n1 in range(joining_torso._elementsCount[1] + 1): + joining_torso.nodeId[1][n2][n1] = torso.nodeId[0][n2][4 - n1] + joining_torso.px[1][n2][n1] = torso.px[0][n2][4 - n1] + joining_torso.pd1[1][n2][n1] = torso.pd1[0][n2][4 - n1] + joining_torso.pd2[1][n2][n1] = torso.pd2[0][n2][4 - n1] + joining_torso.pd3[1][n2][n1] = torso.pd3[0][n2][4 - n1] + + if n1 <= joining_torso._elementsCount[0]//2: + joining_torso.nodeId[0][n2][n1] = shoulder_joint.nodeId[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.px[0][n2][n1] = shoulder_joint.px[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd1[0][n2][n1] = shoulder_joint.pd1[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd2[0][n2][n1] = shoulder_joint.pd2[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd3[0][n2][n1] = shoulder_joint.pd3[0][n2][joining_torso._elementsCount[0] - n1] + else: + joining_torso.nodeId[0][n2][n1] = bottom_joint.nodeId[1][n2][n1] + joining_torso.px[0][n2][n1] = bottom_joint.px[1][n2][n1] + joining_torso.pd1[0][n2][n1] = bottom_joint.pd1[1][n2][n1] + joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] + joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] + + + + + + def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): + """ + + :param shoulder_connecting_to_box: + :param joining_box: + :param shoulder_part: + :return: + """ + for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): + for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): + shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] + shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd2[cidxs[0]][n2][n1] = cylinder_part.pd2[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd3[cidxs[0]][n2][n1] = cylinder_part.pd3[cidxs[1]][n2][n1] + + shoulder_connecting_to_box.nodeId[bidx][n2][2] = joining_box.nodeId[1][n2][1] + shoulder_connecting_to_box.px[bidx][n2][2] = joining_box.px[1][n2][1] + shoulder_connecting_to_box.pd1[bidx][n2][2] = joining_box.pd1[1][n2][1] + shoulder_connecting_to_box.pd2[bidx][n2][2] = joining_box.pd2[1][n2][1] + shoulder_connecting_to_box.pd3[bidx][n2][2] = joining_box.pd3[1][n2][1] + + def join_box_to_bottom_and_shoulder(self, joining_box, bottom_part, shoulder_part): + """ + + :param bottom_part: + :param shoulder_part: + :return: + """ + + for n2 in range(bottom_part._elementsCount[1] + 1): + for n1 in range(2): + joining_box.nodeId[0][n2][n1] = bottom_part.nodeId[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.px[0][n2][n1] = bottom_part.px[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd1[0][n2][n1] = bottom_part.pd1[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd2[0][n2][n1] = bottom_part.pd2[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd3[0][n2][n1] = bottom_part.pd3[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.nodeId[1][n2][0] = shoulder_part.nodeId[0][n2][2] + joining_box.px[1][n2][0] = shoulder_part.px[0][n2][2] + joining_box.pd1[1][n2][0] = shoulder_part.pd1[0][n2][2] + joining_box.pd2[1][n2][0] = shoulder_part.pd2[0][n2][2] + joining_box.pd3[1][n2][0] = shoulder_part.pd3[0][n2][2] + + def remove_duplicate_nodes_from_shoulder(self, shoulder_part): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ + (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1): + shoulder_part.px[n3][n2][n1] = None + shoulder_part.pd1[n3][n2][n1] = None + shoulder_part.pd2[n3][n2][n1] = None + shoulder_part.pd3[n3][n2][n1] = None + + def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ + (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1): + n3b = bottom_part._elementsCount[2] + shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2][n1] + shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2][n1] + shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2][n1] + shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2][n1] + shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2][n1] + def copyBaseLeg2Bifurcation(self, baseleg, idx): """ @@ -166,7 +377,7 @@ def copyBaseLeg2Bifurcation(self, baseleg, idx): self.pd2[n3s][n2][n1] = None self.pd3[n3s][n2][n1] = None - def generateNodes(self, nodes, fieldModule, coordinates): + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): """ Create cylinder nodes from coordinates. :param nodes: nodes from coordinates. @@ -175,10 +386,10 @@ def generateNodes(self, nodes, fieldModule, coordinates): """ nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) self._startNodeIdentifier = nodeIdentifier - nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier) + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) self._endNodeIdentifier = nodeIdentifier - def generateElements(self, mesh, fieldModule, coordinates): + def generateElements(self, mesh, fieldModule, coordinates, part_structure): """ Create cylinder elements from nodes. :param mesh: @@ -187,10 +398,10 @@ def generateElements(self, mesh, fieldModule, coordinates): """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier - elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, []) + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) self._endElementIdentifier = elementIdentifier - def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier): + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): """ Create shield nodes from coordinates. """ @@ -205,22 +416,22 @@ def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier): nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) cache = fieldmodule.createFieldcache() - for n3 in range(self._elementsCount[2] + 2): - for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 1): - if self.px[n3][n2][n1]: + for n3 in range(part_structure._elementsCount[2] + 1): + for n2 in range(part_structure._elementsCount[1] + 1): + for n1 in range(part_structure._elementsCount[0] + 1): + if part_structure.px[n3][n2][n1]: node = nodes.createNode(nodeIdentifier, nodetemplate) - self.nodeId[n3][n2][n1] = nodeIdentifier + part_structure.nodeId[n3][n2][n1] = nodeIdentifier cache.setNode(node) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, self.px [n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, self.pd1[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, self.pd2[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, self.pd3[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) nodeIdentifier += 1 return nodeIdentifier - def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroups=[]): + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, meshGroups=[]): """ Create shield elements from nodes. :param fieldmodule: Zinc fieldmodule to create elements in. @@ -245,215 +456,266 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # isEven = (self.elementsCountAcross % 2) == 0 e1a = 0 e1b = e1a + 1 - e1z = 2*self._elementsCount[0] - 1 + e1z = part_structure._elementsCount[0] - 1 e1y = e1z - 1 e2a = 0 e2b = e2a + 1 e2c = e2a + 2 - e2z = 2*self._elementsCount[1]-1 + e2z = part_structure._elementsCount[1]-1 e2y = e2z - 1 # e2x = e2z - 2 - for e3 in range(self._elementsCount[2]): - for e2 in range(self._elementsCount[1]): - for e1 in range(self._elementsCount[0]): + for e3 in range(part_structure._elementsCount[2]): + for e2 in range(part_structure._elementsCount[1]): + for e1 in range(part_structure._elementsCount[0]): eft1 = eft scalefactors = None - if e3 >= 3: - e3t = e3 + 1 - else: - e3t = e3 - nids = [ self.nodeId[e3t][e2][e1], self.nodeId[e3t][e2 + 1][e1], self.nodeId[e3t+1][e2][e1], self.nodeId[e3t+1][e2 + 1][e1], - self.nodeId[e3t][e2][e1 + 1], self.nodeId[e3t][e2 + 1][e1 + 1], self.nodeId[e3t+1][e2][e1 + 1], self.nodeId[e3t+1][e2 + 1][e1 + 1] ] - - if (e2 < e2b) or (e2 > e2y): - if (e1 < e1b) or (e1 > e1y): - continue # no element due to triple point closure - if (e2 < e2a) or (e2 > e2z): - if e2 < e2a: - nids = [self.nodeId[e3][e2+1][e1], self.nodeId[e3][e2+1][e1+1], self.nodeId[e3+1][e2+1][e1], self.nodeId[e3+1][e2+1][e1+1], - self.nodeId[e3][e2][e1], self.nodeId[e3][e2][e1+1], self.nodeId[e3+1][e2][e1], self.nodeId[e3+1][e2][e1+1]] - elif e2 > e2z: - nids = [self.nodeId[e3][e2][e1+1], self.nodeId[e3][e2][e1], self.nodeId[e3+1][e2][e1+1], self.nodeId[e3+1][e2][e1], - self.nodeId[e3][e2+1][e1+1], self.nodeId[e3][e2+1][e1], self.nodeId[e3+1][e2+1][e1+1], self.nodeId[e3+1][e2+1][e1]] - elif (e2 == e2a) or (e2 == e2z): - # bottom and top row elements + # if e3 >= 3: + # e3t = e3 + 1 + # else: + # e3t = e3 + # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], + # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], + # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], + # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] + nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + + if isinstance(part_structure, JoiningBox): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2a or e2 == e2z: if e2 == e2a: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e3 == self._elementsCount[2] // 2 + 1 and e1 == e1b: - e3r = e3t-1 - nids[0] = self.nodeId[e3r][e2][e1] - nids[1] = self.nodeId[e3r][e2 + 1][e1] - - if e3 == 2: - remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - elif e3 == 3: - if e1 == e1b: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - else: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - else: + else: + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: + # e3r = e3t-1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + + # if e3 == 2: + # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # elif e3 == 3: + # if e1 == e1b: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder: + if e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # else: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + + # else: + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - - if (e1 == e1b) or (e1 == e1y): - # map bottom triple point element - if e1 == e1b: - if e3 != 2: - remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - else: - remapEftNodeValueLabel(eft1, [ 6, 8 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) - elif e2 == e2z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) - if (e1 == e1b) or (e1 == e1y): - # map top triple point element - if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - else: - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) - - elif (e2 == e2b) or (e2 == e2y): - if (e1 <= e1a) or (e1 >= e1z): - if e1 < e1a: - e2r = e1 - if e2 == e2b: - nids = [self.nodeId[e3][e2c][e1+1], self.nodeId[e3][e2r+1][e1b], self.nodeId[e3+1][e2c][e1+1], self.nodeId[e3+1][e2r+1][e1b], - self.nodeId[e3][e2c][e1], self.nodeId[e3][e2r][e1b], self.nodeId[e3+1][e2c][e1], self.nodeId[e3+1][e2r][e1b]] - if e2 == e2y: - e2r = 2*self._elementsCount[1] - e1-1 - nids = [self.nodeId[e3][e2r][e1b], self.nodeId[e3][e2y][e1+1], self.nodeId[e3+1][e2r][e1b], self.nodeId[e3+1][e2y][e1+1], - self.nodeId[e3][e2r+1][e1b], self.nodeId[e3][e2y][e1], self.nodeId[e3+1][e2r+1][e1b], self.nodeId[e3+1][e2y][e1]] - elif e1 == e1a: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == e2b: - if e3 == self._elementsCount[2] // 2 + 1: - e3r = e3-1 # to join upper leg with the lower leg. - nids[0] = self.nodeId[e3r][e2a][e1b] - nids[2] = self.nodeId[e3+1][e2a][e1b] - nids[1] = self.nodeId[e3r][e2 + 1][e1] - nids[4] = self.nodeId[e3r][e2][e1 + 1] - nids[5] = self.nodeId[e3r][e2 + 1][e1 + 1] - else: - nids[0] = self.nodeId[e3][e2a][e1b] - nids[2] = self.nodeId[e3+1][e2a][e1b] - tripleN = [5, 7] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - elif e2 == e2y: - nids[1] = self.nodeId[e3][e2z+1][e1b] - nids[3] = self.nodeId[e3+1][e2z+1][e1b] - tripleN = [6, 8] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - 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 e1 == e1z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2b: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + # if e3 != 2: + # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - 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] - nids[7] = self.nodeId[e3+1][e2z+1][e1z] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - elif e1 > e1z: - e2r = self._elementsCount[0] - e1 - if e2 == e2b: - nids = [self.nodeId[e3][e2r][e1z], self.nodeId[e3][e2c][e1], self.nodeId[e3+1][e2r][e1z], self.nodeId[e3+1][e2c][e1], - self.nodeId[e3][e2r-1][e1z], self.nodeId[e3][e2c][e1+1], self.nodeId[e3+1][e2r-1][e1z], self.nodeId[e3+1][e2c][e1+1]] - elif e2 == e2y: - e2r = e2z+e1-e1z - nids[1] = self.nodeId[e3][e2r][e1z] - nids[3] = self.nodeId[e3+1][e2r][e1z] - nids[5] = self.nodeId[e3][e2r+1][e1z] - nids[7] = self.nodeId[e3+1][e2r+1][e1z] - elif e1 == e1b: - if e2 == e2b: - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e3 == self._elementsCount[2] // 2 + 1: - e3r = e3 - 1 - nids[0] = self.nodeId[e3r][e2][e1] - nids[1] = self.nodeId[e3r][e2 + 1][e1] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - if e3 == 2: + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder and e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*part_structure._elementsCount[1] - e1-1 + nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - - - - - - else: - if e1 < e1a: - nids = [ self.nodeId[e3][e2 + 1][e1 + 1], self.nodeId[e3][e2][e1 + 1], self.nodeId[e3+1][e2 + 1][e1 + 1], self.nodeId[e3+1][e2][e1 + 1], - self.nodeId[e3][e2 + 1][e1], self.nodeId[e3][e2][e1], self.nodeId[e3+1][e2 + 1][e1], self.nodeId[e3+1][e2][e1]] - elif e1 == e1a: - # map left column elements - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) - - if e3 == 2: - if e1 == e1b: - # joining elements - if e2 == 0: - nids = [15, 17, 22, 24, 16, 18, 23, 25] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + 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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.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] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e1 > e1z: + e2r = part_structure._elementsCount[0] - e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = part_structure.nodeId[e3][e2r][e1z] + nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + # if e3 == part_structure._elementsCount[2] // 2 + 1: + # e3r = e3 - 1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # if e3 == 2: + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - elif e2 == 1: - nids = [17, 20, 24, 26, 18, 21, 25, 27] - print(e3, e2, e1) - print(nids) + else: + if e1 < e1a: + nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) + + # if e3 == 2: + # if e1 == e1b: + # # joining elements + # if e2 == 0: + # nids = [15, 17, 22, 24, 16, 18, 23, 25] + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + + + + + # elif e2 == 1: + # nids = [17, 20, 24, 26, 18, 21, 25, 27] if not all(nids): continue @@ -469,7 +731,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: result3 = 7 #print('create element shield', elementIdentifier, result2, result3, nids) - self.elementId[e3][e2][e1] = elementIdentifier + part_structure.elementId[e3][e2][e1] = elementIdentifier elementIdentifier += 1 for meshGroup in meshGroups: @@ -490,9 +752,10 @@ def __init__(self, elementsCount, nodeparams): :param mesh: :param nodes: """ - elementsCount = [2, 2, 2] - self._elementsCount = elementsCount + elementsCount = [4, 4, 2] + self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] self.nodeparams = nodeparams + self._shoulder = False self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] @@ -502,6 +765,41 @@ def __init__(self, elementsCount, nodeparams): self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] self.generateBaseLeg(nodeparams) + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1): + n3q = n3 + n2q = elementsCount[1] - n2 + n1q = n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): + n3q = n3 + n2q = n2 + n1q = elementsCount[0] - n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + else: + self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self._elementsCount = elementsCount + def generateBaseLeg(self, nodeparams): """ Generate base leg that is a cylinder generated from cylinder ends. @@ -718,3 +1016,65 @@ def copyEllipseNodesToBifurcation(self, ellipse, n3): self.pd1[n3][n2][n1] = ellipse.pd1[n2e][n1e] self.pd2[n3][n2][n1] = ellipse.pd2[n2e][n1e] self.pd3[n3][n2][n1] = ellipse.pd3[n2e][n1e] + + +class JoiningBox: + def __init__(self, elementsCount): + self._elementsCount = elementsCount + self._joining_box = True + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + self.px[1][0][1] = [0.0, 1.0, 2.2] + self.px[1][1][1] = [0.0, 0.5, 2.2] + self.px[1][2][1] = [0.0, 0.0, 2.2] + self.px[1][3][1] = [0.0, -0.5, 2.2] + self.px[1][4][1] = [0.0, -1.0, 2.2] + for n2 in range(elementsCount[1]+1): + self.pd1[1][n2][1] = [0.0, -0.5, 0.0] + self.pd2[1][n2][1] = [0.5, 0.0, 0.0] + self.pd3[1][n2][1] = [0.0, 0.0, 0.7] + + +class CylinderConnectingToBox: + """ + + """ + def __init__(self, cylinder_part, idxs, sign): + elementsCount = [cylinder_part._elementsCount[0], cylinder_part._elementsCount[1], 1] + self._elementsCount = elementsCount + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0]//2 + 1, elementsCount[0] + 1): + if cylinder_part.px[idxs[0]][n2][n1]: + self.px[idxs[0]][n2][n1] = vector.addVectors([cylinder_part.px[idxs[1]][n2][n1], + cylinder_part.pd2[idxs[1]][n2][n1]], [1, sign]) + self.pd1[idxs[0]][n2][n1] = cylinder_part.pd1[idxs[1]][n2][n1] + self.pd2[idxs[0]][n2][n1] = cylinder_part.pd2[idxs[1]][n2][n1] + self.pd3[idxs[0]][n2][n1] = cylinder_part.pd3[idxs[1]][n2][n1] + + +class JoiningTorso: + def __init__(self, elementsCount): + self._elementsCount = elementsCount + self._joining_torso = True + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + diff --git a/src/scaffoldmaker/utils/geometry.py b/src/scaffoldmaker/utils/geometry.py index a4771915..d40bba04 100644 --- a/src/scaffoldmaker/utils/geometry.py +++ b/src/scaffoldmaker/utils/geometry.py @@ -515,3 +515,19 @@ def createEllipsePoints(cx, radian, axis1, axis2, elementsCountAround, startRadi return px, pd1 + +def get_plane_normal_vector_and_distance(p1, p2, p3): + """ + Find plane equation using three points on the plane. n.r - d = 0 + :param P1, P2, P3: Points on the plane given as a list + :return: normal to vector and distance from origin. + """ + v = vector.addVectors([p2, p1], [1, -1]) + w = vector.addVectors([p3, p1], [1, -1]) + n = vector.normalise(vector.crossproduct3(v, w)) + d = vector.dotproduct(n, p1) + + return n, d + + + From f31264168acf95865022fae63aaa70c7284288da Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 6 Jan 2022 12:27:49 +1300 Subject: [PATCH 08/38] copied to 2nd one --- .../meshtype_3d_solidbifurcation2.py | 209 ++++++++++++++++++ src/scaffoldmaker/scaffolds.py | 10 + 2 files changed, 219 insertions(+) create mode 100644 src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py new file mode 100644 index 00000000..7654a6b7 --- /dev/null +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -0,0 +1,209 @@ +""" +Generates a solid cylinder using a ShieldMesh of all cube elements, + with variable numbers of elements in major, minor, shell and axial directions. +""" + +from __future__ import division +import math +import copy +from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates +from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base +from scaffoldmaker.utils.meshrefinement import MeshRefinement +from scaffoldmaker.utils.cylindermesh import CylinderMesh, CylinderShape, CylinderEnds, CylinderCentralPath +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import MeshType_1d_bifurcationtree1 +from opencmiss.zinc.node import Node +from scaffoldmaker.utils.bifurcation3d import BifurcationMesh + + +class MeshType_3d_solidbifurcation2(Scaffold_base): + """ +Generates a solid cylinder using a ShieldMesh of all cube elements, +with variable numbers of elements in major, minor, shell and axial directions. + """ + centralPathDefaultScaffoldPackages = { + # 'Cylinder 1': ScaffoldPackage(MeshType_1d_path1, { + # 'scaffoldSettings': { + # 'Coordinate dimensions': 3, + # 'D2 derivatives': True, + # 'D3 derivatives': True, + # 'Length': 3.0, + # 'Number of elements': 3 + # }#, + # # 'meshEdits': exnodeStringFromNodeValues( + # # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + # # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + # # [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # # [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # # [[0.0, 0.0, 2.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # # [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] + # # ]) + # }), + 'control curves': ScaffoldPackage(MeshType_1d_bifurcationtree1, { + 'scaffoldSettings': { + 'Number of generations' : 2, + 'Root diameter' : 0.25, + 'Root length' : 1.0, + 'Fork angle degrees' : 10.0, + 'Fork diameter ratio' : 0.9, + 'Branch arc angle degrees' : 40.0, + 'Branch diameter ratio' : 0.8, + 'Branch length ratio' : 0.8 + } + }) + } + + @staticmethod + def getName(): + return '3D Solid Bifurcation 2' + + @classmethod + def getDefaultOptions(cls, parameterSetName='Default'): + centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] + options = { + 'Central path': copy.deepcopy(centralPathOption), + 'Number of elements across major': 4, + 'Number of elements across minor': 4, + 'Number of elements across shell': 0, + 'Number of elements across transition': 1, + 'Number of elements along': 1, + 'Shell element thickness proportion': 1.0, + 'Lower half': False, + 'Use cross derivatives': False, + 'Refine': False, + 'Refine number of elements across major': 1, + 'Refine number of elements along': 1 + } + return options + + @staticmethod + def getOrderedOptionNames(): + return [ + 'Central path', + 'Number of elements across major', + 'Number of elements across minor', + 'Number of elements across shell', + 'Number of elements across transition', + 'Number of elements along', + 'Shell element thickness proportion', + 'Lower half', + 'Refine', + 'Refine number of elements across major', + 'Refine number of elements along' + ] + + @classmethod + def getOptionValidScaffoldTypes(cls, optionName): + if optionName == 'Central path': + return [MeshType_1d_path1] + return [] + + @classmethod + def getOptionScaffoldTypeParameterSetNames(cls, optionName, scaffoldType): + if optionName == 'Central path': + return list(cls.centralPathDefaultScaffoldPackages.keys()) + assert scaffoldType in cls.getOptionValidScaffoldTypes(optionName), \ + cls.__name__ + '.getOptionScaffoldTypeParameterSetNames. ' + \ + 'Invalid option \'' + optionName + '\' scaffold type ' + scaffoldType.getName() + return scaffoldType.getParameterSetNames() + + @classmethod + def getOptionScaffoldPackage(cls, optionName, scaffoldType, parameterSetName=None): + ''' + :param parameterSetName: Name of valid parameter set for option Scaffold, or None for default. + :return: ScaffoldPackage. + ''' + if parameterSetName: + assert parameterSetName in cls.getOptionScaffoldTypeParameterSetNames(optionName, scaffoldType), \ + 'Invalid parameter set ' + str(parameterSetName) + ' for scaffold ' + str(scaffoldType.getName()) + \ + ' in option ' + str(optionName) + ' of scaffold ' + cls.getName() + if optionName == 'Central path': + if not parameterSetName: + parameterSetName = list(cls.centralPathDefaultScaffoldPackages.keys())[0] + return copy.deepcopy(cls.centralPathDefaultScaffoldPackages[parameterSetName]) + assert False, cls.__name__ + '.getOptionScaffoldPackage: Option ' + optionName + ' is not a scaffold' + + @classmethod + def checkOptions(cls, options): + if not options['Central path'].getScaffoldType() in cls.getOptionValidScaffoldTypes('Central path'): + options['Central path'] = cls.getOptionScaffoldPackage('Central path', MeshType_1d_path1) + dependentChanges = False + + if options['Number of elements across major'] < 4: + options['Number of elements across major'] = 4 + if options['Number of elements across major'] % 2: + options['Number of elements across major'] += 1 + + if options['Number of elements across minor'] < 4: + options['Number of elements across minor'] = 4 + if options['Number of elements across minor'] % 2: + options['Number of elements across minor'] += 1 + if options['Number of elements along'] < 1: + options['Number of elements along'] = 1 + if options['Number of elements across transition'] < 1: + options['Number of elements across transition'] = 1 + Rcrit = min(options['Number of elements across major']-4, options['Number of elements across minor']-4)//2 + if options['Number of elements across shell'] + options['Number of elements across transition'] - 1 > Rcrit: + dependentChanges = True + options['Number of elements across shell'] = Rcrit + options['Number of elements across transition'] = 1 + + if options['Shell element thickness proportion'] < 0.15: + options['Shell element thickness proportion'] = 1.0 + + return dependentChanges + + @staticmethod + def generateBaseMesh(region, options): + """ + Generate the base tricubic Hermite mesh. See also generateMesh(). + :param region: Zinc region to define model in. Must be empty. + :param options: Dict containing options. See getDefaultOptions(). + :return: None + """ + + 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'] + elementsCountAlong = options['Number of elements along'] + shellProportion = options['Shell element thickness proportion'] + useCrossDerivatives = options['Use cross derivatives'] + + fm = region.getFieldmodule() + coordinates = findOrCreateFieldCoordinates(fm) + + # cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) + # + # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF + # + # base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, + # elementsCountAcrossTransition, + # shellProportion, + # [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + # cylinderCentralPath.minorRadii[0]) + # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, + # cylinderShape=cylinderShape, + # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + bifurcation1 = BifurcationMesh(fm, coordinates, region) + + annotationGroup = [] + return annotationGroup + + @classmethod + def refineMesh(cls, meshRefinement, options): + """ + Refine source mesh into separate region, with change of basis. + :param meshRefinement: MeshRefinement, which knows source and target region. + :param options: Dict containing options. See getDefaultOptions(). + """ + assert isinstance(meshRefinement, MeshRefinement) + refineElementsCountAcrossMajor = options['Refine number of elements across major'] + refineElementsCountAlong = options['Refine number of elements along'] + meshRefinement.refineAllElementsCubeStandard3d(refineElementsCountAcrossMajor, refineElementsCountAlong, refineElementsCountAcrossMajor) diff --git a/src/scaffoldmaker/scaffolds.py b/src/scaffoldmaker/scaffolds.py index 2de62b26..a6d83be3 100644 --- a/src/scaffoldmaker/scaffolds.py +++ b/src/scaffoldmaker/scaffolds.py @@ -38,6 +38,11 @@ from scaffoldmaker.meshtypes.meshtype_3d_ostium1 import MeshType_3d_ostium1 from scaffoldmaker.meshtypes.meshtype_3d_smallintestine1 import MeshType_3d_smallintestine1 <<<<<<< HEAD +<<<<<<< HEAD +======= +from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation1 import MeshType_3d_solidbifurcation1 +from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation2 import MeshType_3d_solidbifurcation2 +>>>>>>> cfec53f (copied to 2nd one) from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere2 import MeshType_3d_solidsphere2 @@ -96,6 +101,11 @@ def __init__(self): MeshType_3d_ostium1, MeshType_3d_smallintestine1, <<<<<<< HEAD +<<<<<<< HEAD +======= + MeshType_3d_solidbifurcation1, + MeshType_3d_solidbifurcation2, +>>>>>>> cfec53f (copied to 2nd one) MeshType_3d_solidcylinder1, MeshType_3d_solidsphere1, MeshType_3d_solidsphere2, From b05547110699b6221e0769e9659a7cfa91672489 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 14 Jan 2022 14:54:44 +1300 Subject: [PATCH 09/38] Add neck --- src/scaffoldmaker/utils/bifurcation3d.py | 375 ++++++++++++++++------- 1 file changed, 268 insertions(+), 107 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index e5eb082d..7be38849 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -57,15 +57,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) mesh = fieldmodule.findMeshByDimension(3) - nodeparams1 = [[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]], - [[0.0, 1/self._elementsCount[1], 0.0], [0.0, 1/self._elementsCount[1], 0.0]]], - [[0.0, 0.0, 1.4], [1.2, 0.0, 1.0], [0.0, 1.0, 1.4], [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]], - [[0.0, 1/self._elementsCount[1], 0.0], [0.0, 1/self._elementsCount[1], 0.0]]]] - - nodeparams2 = [[[0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], - [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]], - [[1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], - [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]]] + nodeparams1, nodeparams2 = self._get_node_params() bottom_part = BaseLeg(self._elementsCount, nodeparams1) # self.copyBaseLeg2Bifurcation(baseleg1, 1) @@ -88,65 +80,115 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) self.generateElements(mesh, fieldmodule, coordinates, joining_box) - shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) - self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) - self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) - self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) - - bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) - self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) - self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) - self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) - - centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] - outer_point = [4.417e-01, 4.174e-02, 3.897e+00] - - p1 = [-1.12e+00, 9.29e-02, 3.22e+00] - p2 = [-1.62e+00, 1.061e-01, 3.72e+00] - p3 = [-2.12e+00, 1.14e-01, 4.26e+00] - p4 = [-2.605e+00, 1.22e-01, 4.76e+00] - d11 = vector.addVectors([p1, centre], [1, -1]) - d21 = vector.addVectors([outer_point, centre], [1, -1]) - d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) - - - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 3.0, - 'Number of elements': 4 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] - ]) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(4, 4, 0, 1, 1.0, - centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - - joining_torso = JoiningTorso([4, 4, 1]) - self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) - print(joining_torso.nodeId) - self.generateElements(mesh, fieldmodule, coordinates, joining_torso) - - - torso_part = torso_cylinder._shield + x_shoulder_base_centre = [-0.5, 0.0, 2.2] + x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] + x_shoulder_base_curve1 = [-0.5, 1.0, 2.2] + d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] + x_shoulder_end_centre = [-1.7, 0.0, 2.2] + x_shoulder_end_curve2 = [-1.7, 0.0, 1.2] + x_shoulder_end_curve1 = [-1.7, 1.0, 2.2] + d1_shoulder_end_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]] + d1_shoulder_end_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + + nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + shoulder_part = BaseLeg(self._elementsCount, nodeparams3) + shoulder_part._shoulder = True + + self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + + + + x_neck_base_centre = [0.0, 0.0, 2.62] + x_neck_base_curve2 = [0.0, 1.0, 2.62] + x_neck_base_curve1 = [1.2, 0.0, 3.4] + d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] + x_neck_end_centre = [0.0, 0.0, 3.6] + x_neck_end_curve2 = [0.0, 0.8, 3.6] + x_neck_end_curve1 = [0.8, 0.0, 3.6] + d1_neck_end_curve2 = [[0.0, 0.8 / self._elementsCount[1], 0.0], [0.0, 0.8 / self._elementsCount[1], 0.0]] + d1_neck_end_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [1 / self._elementsCount[0], 0.0, 0.0]] + + nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, + d1_neck_base_curve2], + [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, + d1_neck_end_curve2]] + + neck_part = BaseLeg(self._elementsCount, nodeparams3) + neck_part._shoulder = True + + # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) + self.generateNodes(nodes, fieldmodule, coordinates, neck_part) + # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, neck_part) + + # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) + # + # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) + # + # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] + # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] + # + # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] + # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] + # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] + # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] + # d11 = vector.addVectors([p1, centre], [1, -1]) + # d21 = vector.addVectors([outer_point, centre], [1, -1]) + # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) + + + # centralPath = ScaffoldPackage(MeshType_1d_path1, { + # 'scaffoldSettings': { + # 'Coordinate dimensions': 3, + # 'D2 derivatives': True, + # 'D3 derivatives': True, + # 'Length': 3.0, + # 'Number of elements': 4 + # }, + # 'meshEdits': exnodeStringFromNodeValues( + # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] + # ]) + # }) + # + # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) + # + # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + # + # base = CylinderEnds(4, 4, 0, 1, 1.0, + # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + # cylinderCentralPath.minorRadii[0]) + # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, + # cylinderShape=cylinderShape, + # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + + # joining_torso = JoiningTorso([4, 4, 1]) + # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) + # print(joining_torso.nodeId) + # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) + # + # + # torso_part = torso_cylinder._shield # -4.990e+00, -7.830e-01, 5.4884e+00 @@ -164,32 +206,32 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # -6.031e+00, 9.325e-02, 3.393e+00 - nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], - [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], - [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], - [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] + # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], + # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], + # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], + # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] - bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) - - self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) - self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) - - # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], - # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], - # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], - # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] - - nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], - [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], - [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], - [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] - - shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) - shoulder_part2._shoulder = True - - self.remove_duplicate_nodes_from_shoulder(shoulder_part2) - self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) - self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) + # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) + # + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) + # + # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], + # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], + # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], + # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] + # + # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], + # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], + # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], + # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] + # + # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) + # shoulder_part2._shoulder = True + # + # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) + # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) # # joining_box = JoiningBox([1, 4, 1]) @@ -242,6 +284,50 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # self.generateNodes(nodes, fieldmodule, coordinates) # self.generateElements(mesh, fieldmodule, coordinates) + + def _get_node_params(self): + """ + + :return: + """ + x_bottom_base_centre = [0.0, 0.0, 0.0] + x_bottom_base_curve1 = [1.0, 0.0, 0.0] + x_bottom_base_curve2 = [0.0, 1.0, 0.0] + d1_bottom_base_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], + [1/self._elementsCount[0], 0.0, 0.0]] + d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + x_bottom_end_centre = [0.0, 0.0, 1.4] + x_bottom_end_curve1 = [1.2, 0.0, 1.0] + x_bottom_end_curve2 = [0.0, 1.0, 1.4] + d1_bottom_end_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], + [0.5*0.7071, 0.0, -0.5*0.7071]] + d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + + nodeparams1 = [[x_bottom_base_centre, x_bottom_base_curve1, x_bottom_base_curve2, d1_bottom_base_curve1, + d1_bottom_base_curve2], + [x_bottom_end_centre, x_bottom_end_curve1, x_bottom_end_curve2, d1_bottom_end_curve1, + d1_bottom_end_curve2]] + + x_shoulder_base_centre = [0.5, 0.0, 2.2] + x_shoulder_base_curve1 = [1.2, 0.0, 1.0] + x_shoulder_base_curve2 = [0.5, 1.0, 2.2] + d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + x_shoulder_end_centre = [1.7, 0.0, 2.2] + x_shoulder_end_curve1 = [1.7, 0.0, 1.2] + x_shoulder_end_curve2 = [1.7, 1.0, 2.2] + d1_shoulder_end_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]] + d1_shoulder_end_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + + nodeparams2 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + return nodeparams1, nodeparams2 + def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): """ @@ -318,41 +404,68 @@ def join_box_to_bottom_and_shoulder(self, joining_box, bottom_part, shoulder_par joining_box.pd2[1][n2][0] = shoulder_part.pd2[0][n2][2] joining_box.pd3[1][n2][0] = shoulder_part.pd3[0][n2][2] - def remove_duplicate_nodes_from_shoulder(self, shoulder_part): + def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): """ :param shoulder_part: :param bottom_part: :return: """ + def condition(n2, n1): + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + for n3 in range(1): for n2 in range(shoulder_part._elementsCount[0] + 1): for n1 in range(shoulder_part._elementsCount[1] + 1): - if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ - (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1): + if condition(n2, n1): shoulder_part.px[n3][n2][n1] = None shoulder_part.pd1[n3][n2][n1] = None shoulder_part.pd2[n3][n2][n1] = None shoulder_part.pd3[n3][n2][n1] = None - def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part): + + def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): """ :param shoulder_part: :param bottom_part: :return: """ + def condition(n2, n1): + # if c: + # n2, n1 = n1, n2 + # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ + # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + + def index(n2, n1): + if c: + if n2 == 0 and n1 == 1: + return n1 - 1, 4 - n2 - 1 + if n2 == 0 and n1 == 3: + return n1 + 1, 4 - n2 - 1 + else: + return n1, 4 - n2 + else: + return n2, n1 + for n3 in range(1): for n2 in range(shoulder_part._elementsCount[0] + 1): for n1 in range(shoulder_part._elementsCount[1] + 1): - if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ - (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1): + if condition(n2, n1): + n2b, n1b = index(n2, n1) n3b = bottom_part._elementsCount[2] - shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2][n1] - shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2][n1] - shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2][n1] - shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2][n1] - shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2][n1] + shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2b][n1b] + shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2b][n1b] + shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2b][n1b] + shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] + shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] def copyBaseLeg2Bifurcation(self, baseleg, idx): """ @@ -963,12 +1076,18 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): xi = n/elementsCountAround # ellipse.px[n2][n1][2] = (1 - xi) * ellipse.px[self._elementsCount[1]][0][2] + xi * \ # ellipse.px[0][self._elementsCount[0]][2] - delta = [ellipse.px[0][self._elementsCount[0]][c] - ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), + vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) + delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) + delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) + delta_p_normalmag = vector.dotproduct(delta_p, normal) + delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) delnormag = vector.dotproduct(delta, normal) - delnor = [delnormag*c for c in normal] + delnor = vector.scaleVector(normal, delnormag) if 0 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + +class CrotchEllipses: + def __init__(self): + """ + + """ From 5423bc3fc8620681874f86d0b1e6d259a7dced6e Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 17 Jan 2022 15:19:59 +1300 Subject: [PATCH 10/38] Angle --- .../meshtype_3d_solidbifurcation2.py | 29 +- src/scaffoldmaker/utils/bifurcation3d2.py | 1258 +++++++++++++++++ 2 files changed, 1285 insertions(+), 2 deletions(-) create mode 100644 src/scaffoldmaker/utils/bifurcation3d2.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 7654a6b7..f3f55c44 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -15,7 +15,7 @@ from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import MeshType_1d_bifurcationtree1 from opencmiss.zinc.node import Node -from scaffoldmaker.utils.bifurcation3d import BifurcationMesh +from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh class MeshType_3d_solidbifurcation2(Scaffold_base): @@ -64,6 +64,14 @@ def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] options = { 'Central path': copy.deepcopy(centralPathOption), + 'Torso radius': 1.0, + 'Left arm radius': 1.0, + 'Right arm radius': 1.0, + 'Neck radius': 0.8, + 'Shoulder height': 2.2, + 'Neck height': 3.6, + 'Right arm angle': 0.0, + 'Right arm length': 1.7, 'Number of elements across major': 4, 'Number of elements across minor': 4, 'Number of elements across shell': 0, @@ -82,6 +90,14 @@ def getDefaultOptions(cls, parameterSetName='Default'): def getOrderedOptionNames(): return [ 'Central path', + 'Torso radius', + 'Left arm radius', + 'Right arm radius', + 'Neck radius', + 'Shoulder height', + 'Neck height', + 'Right arm angle', + 'Right arm length', 'Number of elements across major', 'Number of elements across minor', 'Number of elements across shell', @@ -191,7 +207,16 @@ def generateBaseMesh(region, options): # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, # cylinderShape=cylinderShape, # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - bifurcation1 = BifurcationMesh(fm, coordinates, region) + torso_radius = options['Torso radius'] + left_arm_radius = options['Left arm radius'] + right_arm_radius = options['Right arm radius'] + neck_radius = options['Neck radius'] + shoulder_height = options['Shoulder height'] + neck_height = options['Neck height'] + right_arm_angle = options['Right arm angle'] + right_arm_length = options['Right arm length'] + bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, + neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length) annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py new file mode 100644 index 00000000..02b09cce --- /dev/null +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -0,0 +1,1258 @@ +""" +Utility functions for generating a 3-D solid bifurcation. +""" +import copy +from enum import Enum +from scaffoldmaker.utils import vector, geometry +import math +from opencmiss.zinc.field import Field +from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier +from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode +from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ + smoothCubicHermiteDerivativesLine, interpolateSampleLinear +from opencmiss.zinc.node import Node +from scaffoldmaker.utils.mirror import Mirror +from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh +from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite +from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds +from opencmiss.zinc.element import Element +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues + + +class BifurcationMesh: + """ + Bifurction mesh generator. + """ + + def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, + shoulder_height, neck_height, right_arm_angle, right_arm_length): + """ + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + """ + # generate the mesh + elementsCount = [2, 2, 5] + self._elementsCount = elementsCount + self._region = region + + self.torso_radius = torso_radius + self.left_arm_radius = left_arm_radius + self.right_arm_radius = right_arm_radius + self.neck_radius = neck_radius + self.shoulder_height = shoulder_height + self.neck_height = neck_height + self.right_arm_angle = right_arm_angle + self.right_arm_length = right_arm_length + + + self.createBifurcationMesh3d(fieldModule, coordinates) + + def createBifurcationMesh3d(self, fieldmodule, coordinates): + """ + Create a bifurcation. + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + :return: Final values of nextNodeIdentifier, nextElementIdentifier. + """ + # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + nodeparams1, nodeparams2 = self._get_node_params() + + bottom_part = BaseLeg(self._elementsCount, nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + + shoulder_part = BaseLeg(self._elementsCount, nodeparams2) + shoulder_part._shoulder = True + # self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, bottom_part) + + self.remove_duplicate_nodes_from_shoulder(shoulder_part) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + + joining_box = JoiningBox([1, 4, 1], self.shoulder_height) + self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + self.generateElements(mesh, fieldmodule, coordinates, joining_box) + + x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] + x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] + x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] + d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] + x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] + x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] + x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] + d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] + + nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + shoulder_part = BaseLeg(self._elementsCount, nodeparams3) + shoulder_part._shoulder = True + + self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + + + + x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] + d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] + x_neck_end_centre = [0.0, 0.0, self.neck_height] + x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] + x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] + d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] + d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] + + nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, + d1_neck_base_curve2], + [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, + d1_neck_end_curve2]] + + neck_part = BaseLeg(self._elementsCount, nodeparams3) + neck_part._shoulder = True + + # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) + self.generateNodes(nodes, fieldmodule, coordinates, neck_part) + # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, neck_part) + + # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) + # + # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) + # + # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] + # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] + # + # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] + # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] + # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] + # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] + # d11 = vector.addVectors([p1, centre], [1, -1]) + # d21 = vector.addVectors([outer_point, centre], [1, -1]) + # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) + + + # centralPath = ScaffoldPackage(MeshType_1d_path1, { + # 'scaffoldSettings': { + # 'Coordinate dimensions': 3, + # 'D2 derivatives': True, + # 'D3 derivatives': True, + # 'Length': 3.0, + # 'Number of elements': 4 + # }, + # 'meshEdits': exnodeStringFromNodeValues( + # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] + # ]) + # }) + # + # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) + # + # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + # + # base = CylinderEnds(4, 4, 0, 1, 1.0, + # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + # cylinderCentralPath.minorRadii[0]) + # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, + # cylinderShape=cylinderShape, + # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + + # joining_torso = JoiningTorso([4, 4, 1]) + # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) + # print(joining_torso.nodeId) + # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) + # + # + # torso_part = torso_cylinder._shield + + +# -4.990e+00, -7.830e-01, 5.4884e+00 +# +# +# +# -6.480e+00, 1.118e-01, 3.8448e+00 +# +# -4.947e+00, 1.216e-01, 5.4829e+00 +# +# -6.004e+00, -6.005e-01, 3.3709e+00 +#-6.031e+00, 9.325e-02, 3.393e+00 + +# -6.496e+00, -5.925e-01, 3.8599e+00 + + # -6.031e+00, 9.325e-02, 3.393e+00 + + # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], + # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], + # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], + # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] + + # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) + # + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) + # + # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], + # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], + # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], + # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] + # + # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], + # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], + # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], + # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] + # + # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) + # shoulder_part2._shoulder = True + # + # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) + # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) + # + # joining_box = JoiningBox([1, 4, 1]) + # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box) + + + + + # elementsCount = [2, 2, 5] + # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] + # + # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], + # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] + # + # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], + # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] + # + # + # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + # + # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] + # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] + # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] + # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # + # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) + # self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + + def _get_node_params(self): + """ + + :return: + """ + x_bottom_base_centre = [0.0, 0.0, 0.0] + x_bottom_base_curve1 = [self.torso_radius, 0.0, 0.0] + x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] + d1_bottom_base_curve1 = [[self.torso_radius/self._elementsCount[0], 0.0, 0.0], + [self.torso_radius/self._elementsCount[0], 0.0, 0.0]] + d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + x_bottom_end_centre = [0.0, 0.0, 1.4] + x_bottom_end_curve1 = [1.2, 0.0, 1.0] + x_bottom_end_curve2 = [0.0, 1.0, 1.4] + d1_bottom_end_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], + [0.5*0.7071, 0.0, -0.5*0.7071]] + d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + + nodeparams1 = [[x_bottom_base_centre, x_bottom_base_curve1, x_bottom_base_curve2, d1_bottom_base_curve1, + d1_bottom_base_curve2], + [x_bottom_end_centre, x_bottom_end_curve1, x_bottom_end_curve2, d1_bottom_end_curve1, + d1_bottom_end_curve2]] + + x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] + x_shoulder_base_curve1 = [1.2, 0.0, 1.0] + x_shoulder_base_curve2 = [0.75, 1.0, self.shoulder_height] + d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + kv = [0.0, 1.0, 0.0] + cv = [self.right_arm_length, 0.0, 0.0] + cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) + ce = vector.addVectors([cev, [0.0, 0.0, self.shoulder_height]], [1, 1]) + x_shoulder_end_centre = ce + # x_shoulder_end_curve1 = [1.7, 0.0, self.shoulder_height - self.left_arm_radius] + x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) + # x_shoulder_end_curve2 = [1.7, self.left_arm_radius, self.shoulder_height] + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) + d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] + + nodeparams2 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + return nodeparams1, nodeparams2 + + def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): + """ + + :param joining_torso: + :param shoulder_part: + :param bottom_part: + :return: + """ + for n2 in range(joining_torso._elementsCount[1] + 1): + for n1 in range(joining_torso._elementsCount[1] + 1): + joining_torso.nodeId[1][n2][n1] = torso.nodeId[0][n2][4 - n1] + joining_torso.px[1][n2][n1] = torso.px[0][n2][4 - n1] + joining_torso.pd1[1][n2][n1] = torso.pd1[0][n2][4 - n1] + joining_torso.pd2[1][n2][n1] = torso.pd2[0][n2][4 - n1] + joining_torso.pd3[1][n2][n1] = torso.pd3[0][n2][4 - n1] + + if n1 <= joining_torso._elementsCount[0]//2: + joining_torso.nodeId[0][n2][n1] = shoulder_joint.nodeId[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.px[0][n2][n1] = shoulder_joint.px[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd1[0][n2][n1] = shoulder_joint.pd1[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd2[0][n2][n1] = shoulder_joint.pd2[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd3[0][n2][n1] = shoulder_joint.pd3[0][n2][joining_torso._elementsCount[0] - n1] + else: + joining_torso.nodeId[0][n2][n1] = bottom_joint.nodeId[1][n2][n1] + joining_torso.px[0][n2][n1] = bottom_joint.px[1][n2][n1] + joining_torso.pd1[0][n2][n1] = bottom_joint.pd1[1][n2][n1] + joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] + joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] + + + + + + def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): + """ + + :param shoulder_connecting_to_box: + :param joining_box: + :param shoulder_part: + :return: + """ + for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): + for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): + shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] + shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd2[cidxs[0]][n2][n1] = cylinder_part.pd2[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd3[cidxs[0]][n2][n1] = cylinder_part.pd3[cidxs[1]][n2][n1] + + shoulder_connecting_to_box.nodeId[bidx][n2][2] = joining_box.nodeId[1][n2][1] + shoulder_connecting_to_box.px[bidx][n2][2] = joining_box.px[1][n2][1] + shoulder_connecting_to_box.pd1[bidx][n2][2] = joining_box.pd1[1][n2][1] + shoulder_connecting_to_box.pd2[bidx][n2][2] = joining_box.pd2[1][n2][1] + shoulder_connecting_to_box.pd3[bidx][n2][2] = joining_box.pd3[1][n2][1] + + def join_box_to_bottom_and_shoulder(self, joining_box, bottom_part, shoulder_part): + """ + + :param bottom_part: + :param shoulder_part: + :return: + """ + + for n2 in range(bottom_part._elementsCount[1] + 1): + for n1 in range(2): + joining_box.nodeId[0][n2][n1] = bottom_part.nodeId[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.px[0][n2][n1] = bottom_part.px[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd1[0][n2][n1] = bottom_part.pd1[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd2[0][n2][n1] = bottom_part.pd2[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd3[0][n2][n1] = bottom_part.pd3[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.nodeId[1][n2][0] = shoulder_part.nodeId[0][n2][2] + joining_box.px[1][n2][0] = shoulder_part.px[0][n2][2] + joining_box.pd1[1][n2][0] = shoulder_part.pd1[0][n2][2] + joining_box.pd2[1][n2][0] = shoulder_part.pd2[0][n2][2] + joining_box.pd3[1][n2][0] = shoulder_part.pd3[0][n2][2] + + def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + def condition(n2, n1): + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if condition(n2, n1): + shoulder_part.px[n3][n2][n1] = None + shoulder_part.pd1[n3][n2][n1] = None + shoulder_part.pd2[n3][n2][n1] = None + shoulder_part.pd3[n3][n2][n1] = None + + + def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + def condition(n2, n1): + # if c: + # n2, n1 = n1, n2 + # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ + # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + + def index(n2, n1): + if c: + if n2 == 0 and n1 == 1: + return n1 - 1, 4 - n2 - 1 + if n2 == 0 and n1 == 3: + return n1 + 1, 4 - n2 - 1 + else: + return n1, 4 - n2 + else: + return n2, n1 + + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if condition(n2, n1): + n2b, n1b = index(n2, n1) + n3b = bottom_part._elementsCount[2] + shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2b][n1b] + shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2b][n1b] + shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2b][n1b] + shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] + shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] + + def copyBaseLeg2Bifurcation(self, baseleg, idx): + """ + + :return: + """ + for n3 in range(self._elementsCount[2]//2 + 1): + for n2 in range(self._elementsCount[0] + 1): + for n1 in range(self._elementsCount[1] + 1): + if idx == 1: + n3s = n3 + elif idx == 2: + n3s = self._elementsCount[2]//2 + 2 + n3 + self.px[n3s][n2][n1] = baseleg.px[n3][n2][n1] + self.pd1[n3s][n2][n1] = baseleg.pd1[n3][n2][n1] + self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] + self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] + if idx == 2 and n3 == 0: + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): + self.px[n3s][n2][n1] = None + self.pd1[n3s][n2][n1] = None + self.pd2[n3s][n2][n1] = None + self.pd3[n3s][n2][n1] = None + + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): + """ + Create cylinder nodes from coordinates. + :param nodes: nodes from coordinates. + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + self._startNodeIdentifier = nodeIdentifier + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) + self._endNodeIdentifier = nodeIdentifier + + def generateElements(self, mesh, fieldModule, coordinates, part_structure): + """ + Create cylinder elements from nodes. + :param mesh: + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + self._startElementIdentifier = elementIdentifier + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + self._endElementIdentifier = elementIdentifier + + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): + """ + Create shield nodes from coordinates. + """ + nodeIdentifier = startNodeIdentifier + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) + cache = fieldmodule.createFieldcache() + + for n3 in range(part_structure._elementsCount[2] + 1): + for n2 in range(part_structure._elementsCount[1] + 1): + for n1 in range(part_structure._elementsCount[0] + 1): + if part_structure.px[n3][n2][n1]: + node = nodes.createNode(nodeIdentifier, nodetemplate) + part_structure.nodeId[n3][n2][n1] = nodeIdentifier + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + nodeIdentifier += 1 + + return nodeIdentifier + + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, 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 meshGroups: Zinc mesh groups to add elements to. + :return: next elementIdentifier. + """ + elementIdentifier = startElementIdentifier + useCrossDerivatives = False + mesh = fieldmodule.findMeshByDimension(3) + + tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) + eft = tricubichermite.createEftNoCrossDerivatives() + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) + elementtemplate.defineField(coordinates, -1, eft) + + elementtemplate1 = mesh.createElementtemplate() + elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) + + # isEven = (self.elementsCountAcross % 2) == 0 + e1a = 0 + e1b = e1a + 1 + e1z = part_structure._elementsCount[0] - 1 + e1y = e1z - 1 + e2a = 0 + e2b = e2a + 1 + e2c = e2a + 2 + e2z = part_structure._elementsCount[1]-1 + e2y = e2z - 1 + # e2x = e2z - 2 + for e3 in range(part_structure._elementsCount[2]): + for e2 in range(part_structure._elementsCount[1]): + for e1 in range(part_structure._elementsCount[0]): + eft1 = eft + scalefactors = None + # if e3 >= 3: + # e3t = e3 + 1 + # else: + # e3t = e3 + # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], + # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], + # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], + # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] + nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + + if isinstance(part_structure, JoiningBox): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2a or e2 == e2z: + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: + # e3r = e3t-1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + + # if e3 == 2: + # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # elif e3 == 3: + # if e1 == e1b: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder: + if e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # else: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + + # else: + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + # if e3 != 2: + # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder and e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*part_structure._elementsCount[1] - e1-1 + nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + 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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.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] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e1 > e1z: + e2r = part_structure._elementsCount[0] - e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = part_structure.nodeId[e3][e2r][e1z] + nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + # if e3 == part_structure._elementsCount[2] // 2 + 1: + # e3r = e3 - 1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # if e3 == 2: + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + + + + + + else: + if e1 < e1a: + nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) + + # if e3 == 2: + # if e1 == e1b: + # # joining elements + # if e2 == 0: + # nids = [15, 17, 22, 24, 16, 18, 23, 25] + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + + + + + # elif e2 == 1: + # nids = [17, 20, 24, 26, 18, 21, 25, 27] + + if not all(nids): + continue + + if eft1 is not eft: + elementtemplate1.defineField(coordinates, -1, eft1) + element = mesh.createElement(elementIdentifier, elementtemplate1) + else: + element = mesh.createElement(elementIdentifier, elementtemplate) + result2 = element.setNodesByIdentifier(eft1, nids) + if scalefactors: + result3 = element.setScaleFactors(eft1, scalefactors) + else: + result3 = 7 + #print('create element shield', elementIdentifier, result2, result3, nids) + part_structure.elementId[e3][e2][e1] = elementIdentifier + elementIdentifier += 1 + + for meshGroup in meshGroups: + meshGroup.addElement(element) + + return elementIdentifier + + +class BaseLeg: + """ + Base case for creating a child + """ + def __init__(self, elementsCount, nodeparams): + """ + + :param fieldmodule: + :param coordinates: + :param mesh: + :param nodes: + """ + elementsCount = [4, 4, 2] + self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] + self.nodeparams = nodeparams + self._shoulder = False + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.generateBaseLeg(nodeparams) + + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1): + n3q = n3 + n2q = elementsCount[1] - n2 + n1q = n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): + n3q = n3 + n2q = n2 + n1q = elementsCount[0] - n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + else: + self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self._elementsCount = elementsCount + + def generateBaseLeg(self, nodeparams): + """ + Generate base leg that is a cylinder generated from cylinder ends. + :return: + """ + bottomnodeparams = nodeparams[0] + topnodeparams = nodeparams[1] + self.genetateBottomSurface(bottomnodeparams) + self.generateTopSurface(topnodeparams) + self.generateMiddleLevels() + self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateMiddleLevels() + # self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + def genetateBottomSurface(self, bottomnodeparams): + """ + Use major and minor curves to generate the ellipse + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, 0) + + def generateTopSurface(self, topnodeparams): + """ + + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + + def generateMiddleLevels(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # generate the armpit curves. + elementsCountOut = 2 + txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], + btx[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [btd2[0][self._elementsCount[1]][self._elementsCount[0]], + btd2[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + elementsCountOut) + txec1, td1ec1, pec1, pxic1, psfc1 = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][0], btx[self._elementsCount[2]][self._elementsCount[1]][0]], + [btd2[0][self._elementsCount[1]][0], btd2[self._elementsCount[2]][self._elementsCount[1]][0]], + elementsCountOut) + txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]], btx[self._elementsCount[2]][0][self._elementsCount[0]]], + [btd2[0][0][self._elementsCount[0]], btd2[self._elementsCount[2]][0][self._elementsCount[0]]], + elementsCountOut) + + tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][self._elementsCount[0]], + btd3[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]][self._elementsCount[0]], + btd1[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlec1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][0], + btd3[self._elementsCount[2]][self._elementsCount[1]][0]], + [[0.0, 0.0, 0.0]] * 2, pec1, pxic1, psfc1)[0] + tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]], + btd3[self._elementsCount[2]][0][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] + + for n3 in range(1, self._elementsCount[2]): + centre = txcc1[n3] + txc1, td1c1 = self.generate1DPath([centre, txec1[n3]], [[-c for c in tdlcc1[n3]], tdlec1[n3]], self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, n3) + + def smoothd2(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # smooth d2 + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + nx = [] + nd1 = [] + for n3 in range(self._elementsCount[2] + 1): + nx.append(btx[n3][n2][n1]) + nd1.append(btd2[n3][n2][n1]) + td2 = smoothCubicHermiteDerivativesLine(nx, nd1) + for n3 in range(self._elementsCount[2] + 1): + btd2[n3][n2][n1] = td2[n3] + + def generate1DPath(self, nx, nd1, elementsCountOut): + """ + Given end nodes generate 1d path + :return: + """ + tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) + return tx, td1 + + def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): + """ + Get major and minor curves to generate the rounded surface. + :return: + """ + + # self._coreMinorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) + # self._coreMajorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) + + # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 + # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] + # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] + majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] + minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] + elementsCountAcrossShell = 0 + elementsCountAcrossTransition = 1 + shellProportion = 1.0 + coreMajorRadius = 1.0 + coreMinorRadius = 1.0 + elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 + ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + shield = ellipse.getShield() + ellipse.generateBase1DMesh(0) + + ellipse.px[self._elementsCount[1]][0] = txc1[-1] + ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] + ellipse.px[0][self._elementsCount[0]] = txc2[-1] + ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] + + nx = [] + nd1 = [] + for n in range(elementsCountAround + 1): + n1, n2 = shield.convertRimIndex(n) + xi = n/elementsCountAround + # ellipse.px[n2][n1][2] = (1 - xi) * ellipse.px[self._elementsCount[1]][0][2] + xi * \ + # ellipse.px[0][self._elementsCount[0]][2] + x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), + vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) + delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) + delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) + delta_p_normalmag = vector.dotproduct(delta_p, normal) + delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) + delnormag = vector.dotproduct(delta, normal) + delnor = vector.scaleVector(normal, delnormag) + if 0 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + +class CrotchEllipses: + def __init__(self): + """ + + """ From 43dd08e2bf9ef154ba8486bcf06e9d2a4ac4b697 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 3 Feb 2022 15:53:07 +1300 Subject: [PATCH 11/38] fix derivatives --- .../meshtype_3d_solidbifurcation2.py | 18 + src/scaffoldmaker/utils/bifurcation3d2.py | 895 ++++++--- src/scaffoldmaker/utils/bifurcation3d3.py | 1619 +++++++++++++++++ 3 files changed, 2266 insertions(+), 266 deletions(-) create mode 100644 src/scaffoldmaker/utils/bifurcation3d3.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index f3f55c44..6355f4e9 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -64,11 +64,16 @@ def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] options = { 'Central path': copy.deepcopy(centralPathOption), + 'Armpit': [1.3, 0.0, 1.4], 'Torso radius': 1.0, 'Left arm radius': 1.0, 'Right arm radius': 1.0, 'Neck radius': 0.8, + 'Neck shoulder point': [0.7, 0.0, 2.8], 'Shoulder height': 2.2, + 'Shoulder joint': [1.1, 0.0, 2.4], + 'Shoulder point': [1.0, 0.0, 2.8], + 'Shoulder start': [0.5, 0.0, 2.2], 'Neck height': 3.6, 'Right arm angle': 0.0, 'Right arm length': 1.7, @@ -90,11 +95,16 @@ def getDefaultOptions(cls, parameterSetName='Default'): def getOrderedOptionNames(): return [ 'Central path', + 'Armpit', 'Torso radius', 'Left arm radius', 'Right arm radius', 'Neck radius', + 'Neck shoulder point', + 'Shoulder joint', 'Shoulder height', + 'Shoulder point', + 'Shoulder start', 'Neck height', 'Right arm angle', 'Right arm length', @@ -215,6 +225,14 @@ def generateBaseMesh(region, options): neck_height = options['Neck height'] right_arm_angle = options['Right arm angle'] right_arm_length = options['Right arm length'] + shoulder_joint = options['Shoulder joint'] + armpit = options['Armpit'] + neck_shoulder = options['Neck shoulder point'] + shoulder_point = options['Shoulder point'] + shoulder_start = options['Shoulder start'] + # bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, + # neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length, + # shoulder_joint, armpit, neck_shoulder, shoulder_point, shoulder_start) bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 02b09cce..427244fa 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -68,19 +68,14 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) mesh = fieldmodule.findMeshByDimension(3) - nodeparams1, nodeparams2 = self._get_node_params() + nodeparams1, nodeparams2, nodeparams3, nodeparams4 = self._get_node_params() bottom_part = BaseLeg(self._elementsCount, nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - - shoulder_part = BaseLeg(self._elementsCount, nodeparams2) - shoulder_part._shoulder = True - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) self.generateElements(mesh, fieldmodule, coordinates, bottom_part) + shoulder_part = BaseLeg(self._elementsCount, nodeparams2) + shoulder_part._shoulder = True self.remove_duplicate_nodes_from_shoulder(shoulder_part) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) @@ -91,55 +86,30 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) self.generateElements(mesh, fieldmodule, coordinates, joining_box) - x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] - x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] - x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] - d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] - x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] - x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] - x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] - d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] - d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] - - nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, - d1_shoulder_base_curve2], - [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, - d1_shoulder_end_curve2]] - - shoulder_part = BaseLeg(self._elementsCount, nodeparams3) - shoulder_part._shoulder = True - - self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) - self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) - self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + shoulder_part_left = BaseLeg(self._elementsCount, nodeparams3) + shoulder_part_left._shoulder_left = True + self.remove_duplicate_nodes_from_shoulder(shoulder_part_left, 1) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) + self.join_shoulder_to_bottom_part(shoulder_part_left, bottom_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) + neck_part = BaseLeg(self._elementsCount, nodeparams4) + neck_part._neck = True + self.remove_duplicate_nodes_from_neck(neck_part) + self.generateNodes(nodes, fieldmodule, coordinates, neck_part) + self.join_neck_to_torso(neck_part, shoulder_part, shoulder_part_left) + self.generateElements(mesh, fieldmodule, coordinates, neck_part) - x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] - x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] - x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] - d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] - x_neck_end_centre = [0.0, 0.0, self.neck_height] - x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] - x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] - d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] - d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] + joining_box_right = JoiningBoxRight([1, 4, 1], bottom_part, shoulder_part_left, joining_box) + self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) - nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, - d1_neck_base_curve2], - [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, - d1_neck_end_curve2]] + joining_box_3 = JoiningBox3([1, 4, 1], joining_box, neck_part) + self.generateElements(mesh, fieldmodule, coordinates, joining_box_3) - neck_part = BaseLeg(self._elementsCount, nodeparams3) - neck_part._shoulder = True + joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) + self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) - # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) - self.generateNodes(nodes, fieldmodule, coordinates, neck_part) - # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) - self.generateElements(mesh, fieldmodule, coordinates, neck_part) # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) @@ -201,101 +171,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # # torso_part = torso_cylinder._shield - -# -4.990e+00, -7.830e-01, 5.4884e+00 -# -# -# -# -6.480e+00, 1.118e-01, 3.8448e+00 -# -# -4.947e+00, 1.216e-01, 5.4829e+00 -# -# -6.004e+00, -6.005e-01, 3.3709e+00 -#-6.031e+00, 9.325e-02, 3.393e+00 - -# -6.496e+00, -5.925e-01, 3.8599e+00 - - # -6.031e+00, 9.325e-02, 3.393e+00 - - # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], - # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], - # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], - # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] - - # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) - # - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) - # - # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], - # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], - # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], - # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] - # - # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], - # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], - # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], - # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] - # - # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) - # shoulder_part2._shoulder = True - # - # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) - # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) - # - # joining_box = JoiningBox([1, 4, 1]) - # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - - - - # elementsCount = [2, 2, 5] - # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] - # - # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], - # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] - # - # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], - # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] - # - # - # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - # - # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] - # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] - # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] - # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # - # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - def _get_node_params(self): """ @@ -343,7 +218,39 @@ def _get_node_params(self): [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, d1_shoulder_end_curve2]] - return nodeparams1, nodeparams2 + x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] + x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] + x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] + d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] + x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] + x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] + x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] + d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] + + nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] + d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] + x_neck_end_centre = [0.0, 0.0, self.neck_height] + x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] + x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] + d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] + d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] + + nodeparams4 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, + d1_neck_base_curve2], + [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, + d1_neck_end_curve2]] + + return nodeparams1, nodeparams2, nodeparams3, nodeparams4 def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): """ @@ -374,10 +281,6 @@ def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] - - - - def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): """ @@ -443,7 +346,6 @@ def condition(n2, n1): shoulder_part.pd2[n3][n2][n1] = None shoulder_part.pd3[n3][n2][n1] = None - def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): """ @@ -507,6 +409,58 @@ def copyBaseLeg2Bifurcation(self, baseleg, idx): self.pd2[n3s][n2][n1] = None self.pd3[n3s][n2][n1] = None + + def remove_duplicate_nodes_from_neck(self, neck_part): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + for n2 in range(neck_part._elementsCount[1] + 1): + for n1 in range(neck_part._elementsCount[0] + 1): + if n1 != 2: + neck_part.px[0][n2][n1] = None + neck_part.pd1[0][n2][n1] = None + neck_part.pd2[0][n2][n1] = None + neck_part.pd3[0][n2][n1] = None + + def join_neck_to_torso(self, neck_part, shoulder_part, shoulder_part_left): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + for n2 in range(neck_part._elementsCount[1] + 1): + for n1 in range(neck_part._elementsCount[0] + 1): + if n1 < 2: + n1s = 4 - n1 + neck_part.nodeId[0][n2][n1] = shoulder_part.nodeId[0][n2][n1s] + neck_part.px[0][n2][n1] = shoulder_part.px[0][n2][n1s] + neck_part.pd1[0][n2][n1] = shoulder_part.pd1[0][n2][n1s] + neck_part.pd2[0][n2][n1] = shoulder_part.pd2[0][n2][n1s] + neck_part.pd3[0][n2][n1] = shoulder_part.pd3[0][n2][n1s] + elif n1 > 2: + if n2 == 0 or n2 == 4: + if n1 == 3: + n2s = n1+1 + if n2 == 0: + n1s = n2 + 1 + if n2 == 4: + n1s = n2 - 1 + else: + n2s = n1 + n1s = n2 + if n1 == 4: + if n2 !=2: + continue + neck_part.nodeId[0][n2][n1] = shoulder_part_left.nodeId[0][n2s][n1s] + neck_part.px[0][n2][n1] = shoulder_part_left.px[0][n2s][n1s] + neck_part.pd1[0][n2][n1] = shoulder_part_left.pd1[0][n2s][n1s] + neck_part.pd2[0][n2][n1] = shoulder_part_left.pd2[0][n2s][n1s] + neck_part.pd3[0][n2][n1] = shoulder_part_left.pd3[0][n2s][n1s] + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): """ Create cylinder nodes from coordinates. @@ -599,14 +553,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif for e1 in range(part_structure._elementsCount[0]): eft1 = eft scalefactors = None - # if e3 >= 3: - # e3t = e3 + 1 - # else: - # e3t = e3 - # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], - # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], - # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], - # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], @@ -623,6 +569,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) @@ -631,8 +578,10 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) @@ -643,6 +592,321 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + elif isinstance(part_structure, JoiningBoxRight): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + + else: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + elif isinstance(part_structure, JoiningBox3): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1, 3, 5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 2, 5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2, 5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + elif isinstance(part_structure, JoiningBox4): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + + elif part_structure._neck and e3 == 0: + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e1 == e1a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1]), (Node.VALUE_LABEL_D_DS1, [])]) + + else: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1y: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.nodeId[e3+1][e2a][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) + elif e2 == e2y: + nids[5] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + if e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + if e1 < e1a: + nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) else: if (e2 < e2b) or (e2 > e2y): @@ -661,49 +925,55 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: - # e3r = e3t-1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - - # if e3 == 2: - # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # elif e3 == 3: - # if e1 == e1b: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - if isinstance(part_structure, BaseLeg): - if part_structure._shoulder: - if e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # else: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - - # else: - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) + if not part_structure._shoulder_left: + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder: + if e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) if (e1 == e1b) or (e1 == e1y): # map bottom triple point element if e1 == e1b: # if e3 != 2: # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + if part_structure._shoulder_left: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + else: + if part_structure._shoulder: + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if part_structure._shoulder_left: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2z: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -719,6 +989,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # map top triple point element if e1 == e1b: remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) else: remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) @@ -748,8 +1020,16 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: nids[0] = part_structure.nodeId[e3][e2a][e1b] nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - tripleN = [5, 7] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] @@ -761,12 +1041,18 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.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, [] ) ]) + if part_structure._shoulder_left: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + else: + 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] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] @@ -785,24 +1071,24 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1b: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() - # if e3 == part_structure._elementsCount[2] // 2 + 1: - # e3r = e3 - 1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # if e3 == 2: - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - - - - + if part_structure._shoulder_left: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if e2 == e2y: + if part_structure._shoulder: + eft1 = tricubichermite.createEftNoCrossDerivatives() + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + + elif e1 == e1y: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._shoulder_left: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) else: if e1 < e1a: @@ -816,37 +1102,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif 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])]) - # if e3 == 2: - # if e1 == e1b: - # # joining elements - # if e2 == 0: - # nids = [15, 17, 22, 24, 16, 18, 23, 25] - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - - - - - # elif e2 == 1: - # nids = [17, 20, 24, 26, 18, 21, 25, 27] - if not all(nids): continue @@ -886,6 +1141,8 @@ def __init__(self, elementsCount, nodeparams): self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] self.nodeparams = nodeparams self._shoulder = False + self._shoulder_left = False + self._neck = False self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] @@ -942,21 +1199,6 @@ def generateBaseLeg(self, nodeparams): self.generateMiddleLevels() self.smoothd2() - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateMiddleLevels() - # self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - def genetateBottomSurface(self, bottomnodeparams): """ Use major and minor curves to generate the ellipse @@ -1256,3 +1498,124 @@ def __init__(self): """ """ + + +class JoiningBoxRight: + def __init__(self, elementsCount, bottom_part, shoulder_part_left, joining_box): + self._elementsCount = elementsCount + self._joining_box = True + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + for n2 in range(elementsCount[1]+1): + self.nodeId[1][n2][0] = joining_box.nodeId[1][n2][1] + self.px[1][n2][0] = joining_box.px[1][n2][1] + self.pd1[1][n2][0] = joining_box.pd1[1][n2][1] + self.pd2[1][n2][0] = joining_box.pd2[1][n2][1] + self.pd3[1][n2][0] = joining_box.pd3[1][n2][1] + + self.nodeId[0][n2][0] = joining_box.nodeId[0][n2][1] + self.px[0][n2][0] = joining_box.px[0][n2][1] + self.pd1[0][n2][0] = joining_box.pd1[0][n2][1] + self.pd2[0][n2][0] = joining_box.pd2[0][n2][1] + self.pd3[0][n2][0] = joining_box.pd3[0][n2][1] + + self.nodeId[0][n2][1] = bottom_part.nodeId[2][n2][3] + self.px[0][n2][1] = bottom_part.px[2][n2][3] + self.pd1[0][n2][1] = bottom_part.pd1[2][n2][3] + self.pd2[0][n2][1] = bottom_part.pd2[2][n2][3] + self.pd3[0][n2][1] = bottom_part.pd3[2][n2][3] + + n2s = 2 + n1s = n2 + self.nodeId[1][n2][1] = shoulder_part_left.nodeId[0][n2s][n1s] + self.px[1][n2][1] = shoulder_part_left.px[0][n2s][n1s] + self.pd1[1][n2][1] = shoulder_part_left.pd1[0][n2s][n1s] + self.pd2[1][n2][1] = shoulder_part_left.pd2[0][n2s][n1s] + self.pd3[1][n2][1] = shoulder_part_left.pd3[0][n2s][n1s] + + +class JoiningBox3: + def __init__(self, elementsCount, joining_box, neck_part): + self._elementsCount = elementsCount + self._joining_box = True + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + for n2 in range(elementsCount[1]+1): + self.nodeId[0][n2][0] = joining_box.nodeId[1][n2][0] + self.px[0][n2][0] = joining_box.px[1][n2][0] + self.pd1[0][n2][0] = joining_box.pd1[1][n2][0] + self.pd2[0][n2][0] = joining_box.pd2[1][n2][0] + self.pd3[0][n2][0] = joining_box.pd3[1][n2][0] + self.nodeId[0][n2][1] = joining_box.nodeId[1][n2][1] + self.px[0][n2][1] = joining_box.px[1][n2][1] + self.pd1[0][n2][1] = joining_box.pd1[1][n2][1] + self.pd2[0][n2][1] = joining_box.pd2[1][n2][1] + self.pd3[0][n2][1] = joining_box.pd3[1][n2][1] + + self.nodeId[1][n2][0] = neck_part.nodeId[0][n2][1] + self.px[1][n2][0] = neck_part.px[0][n2][1] + self.pd1[1][n2][0] = neck_part.pd1[0][n2][1] + self.pd2[1][n2][0] = neck_part.pd2[0][n2][1] + self.pd3[1][n2][0] = neck_part.pd3[0][n2][1] + + self.nodeId[1][n2][1] = neck_part.nodeId[0][n2][2] + self.px[1][n2][1] = neck_part.px[0][n2][2] + self.pd1[1][n2][1] = neck_part.pd1[0][n2][2] + self.pd2[1][n2][1] = neck_part.pd2[0][n2][2] + self.pd3[1][n2][1] = neck_part.pd3[0][n2][2] + + +class JoiningBox4: + def __init__(self, elementsCount, joining_box_3, neck_part, joining_box_right): + self._elementsCount = elementsCount + self._joining_box = True + self._neck_part = False + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + for n2 in range(elementsCount[1]+1): + self.nodeId[0][n2][0] = joining_box_3.nodeId[0][n2][1] + self.px[0][n2][0] = joining_box_3.px[0][n2][1] + self.pd1[0][n2][0] = joining_box_3.pd1[0][n2][1] + self.pd2[0][n2][0] = joining_box_3.pd2[0][n2][1] + self.pd3[0][n2][0] = joining_box_3.pd3[0][n2][1] + + self.nodeId[1][n2][0] = joining_box_3.nodeId[1][n2][1] + self.px[1][n2][0] = joining_box_3.px[1][n2][1] + self.pd1[1][n2][0] = joining_box_3.pd1[1][n2][1] + self.pd2[1][n2][0] = joining_box_3.pd2[1][n2][1] + self.pd3[1][n2][0] = joining_box_3.pd3[1][n2][1] + + self.nodeId[0][n2][1] = joining_box_right.nodeId[1][n2][1] + self.px[0][n2][1] = joining_box_right.px[1][n2][1] + self.pd1[0][n2][1] = joining_box_right.pd1[1][n2][1] + self.pd2[0][n2][1] = joining_box_right.pd2[1][n2][1] + self.pd3[0][n2][1] = joining_box_right.pd3[1][n2][1] + + self.nodeId[1][n2][1] = neck_part.nodeId[0][n2][3] + self.px[1][n2][1] = neck_part.px[0][n2][3] + self.pd1[1][n2][1] = neck_part.pd1[0][n2][3] + self.pd2[1][n2][1] = neck_part.pd2[0][n2][3] + self.pd3[1][n2][1] = neck_part.pd3[0][n2][3] + + + + + diff --git a/src/scaffoldmaker/utils/bifurcation3d3.py b/src/scaffoldmaker/utils/bifurcation3d3.py new file mode 100644 index 00000000..a0a8ad40 --- /dev/null +++ b/src/scaffoldmaker/utils/bifurcation3d3.py @@ -0,0 +1,1619 @@ +""" +Utility functions for generating a 3-D solid bifurcation. +""" +import copy +from enum import Enum +from scaffoldmaker.utils import vector, geometry +import math +from opencmiss.zinc.field import Field +from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier +from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode +from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ + smoothCubicHermiteDerivativesLine, interpolateSampleLinear +from opencmiss.zinc.node import Node +from scaffoldmaker.utils.mirror import Mirror +from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh +from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite +from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds +from opencmiss.zinc.element import Element +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues + + +class BifurcationMesh: + """ + Bifurction mesh generator. + """ + + def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, + shoulder_height, neck_height, right_arm_angle, right_arm_length, shoulder_joint, armpit, neck_shoulder, + shoulder_point, shoulder_start): + """ + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + """ + # generate the mesh + elementsCount = [2, 2, 5] + self._elementsCount = elementsCount + self._region = region + + self.torso_radius = torso_radius + self.left_arm_radius = left_arm_radius + self.right_arm_radius = right_arm_radius + self.neck_radius = neck_radius + self.shoulder_height = shoulder_height + self.neck_height = neck_height + self.right_arm_angle = right_arm_angle + self.right_arm_length = right_arm_length + self.shoulder_joint = shoulder_joint + self.armpit = armpit + self.neck_shoulder = neck_shoulder + self.shoulder_point = shoulder_point + self.shoulder_start = shoulder_start + + self.createBifurcationMesh3d(fieldModule, coordinates) + + def createBifurcationMesh3d(self, fieldmodule, coordinates): + """ + Create a bifurcation. + :param fieldModule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + :return: Final values of nextNodeIdentifier, nextElementIdentifier. + """ + # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + nodeparams1, nodeparams2 = self._get_node_params() + + bottom_part = BaseLeg2([4, 4, 2], nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + + shoulder_part = BaseLeg2([4, 4, 2], nodeparams2) + # shoulder_part._shoulder = True + # self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, bottom_part) + + # self.remove_duplicate_nodes_from_shoulder(shoulder_part) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + # self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + # + # joining_box = JoiningBox([1, 4, 1], self.shoulder_height) + # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box) + # + # x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] + # x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] + # x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] + # d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + # d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] + # x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] + # x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] + # x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] + # d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] + # d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] + # + # nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, + # d1_shoulder_base_curve2], + # [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, + # d1_shoulder_end_curve2]] + # + # shoulder_part = BaseLeg2(self._elementsCount, nodeparams3) + # shoulder_part._shoulder = True + # + # self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) + # self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + # + # + # + # x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + # x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + # x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] + # d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + # d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] + # x_neck_end_centre = [0.0, 0.0, self.neck_height] + # x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] + # x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] + # d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] + # d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] + # + # nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, + # d1_neck_base_curve2], + # [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, + # d1_neck_end_curve2]] + # + # neck_part = BaseLeg2(self._elementsCount, nodeparams3) + # neck_part._shoulder = True + # + # # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) + # self.generateNodes(nodes, fieldmodule, coordinates, neck_part) + # # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) + # self.generateElements(mesh, fieldmodule, coordinates, neck_part) + + # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) + # + # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) + # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) + # + # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] + # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] + # + # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] + # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] + # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] + # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] + # d11 = vector.addVectors([p1, centre], [1, -1]) + # d21 = vector.addVectors([outer_point, centre], [1, -1]) + # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) + + + # centralPath = ScaffoldPackage(MeshType_1d_path1, { + # 'scaffoldSettings': { + # 'Coordinate dimensions': 3, + # 'D2 derivatives': True, + # 'D3 derivatives': True, + # 'Length': 3.0, + # 'Number of elements': 4 + # }, + # 'meshEdits': exnodeStringFromNodeValues( + # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], + # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] + # ]) + # }) + # + # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) + # + # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + # + # base = CylinderEnds(4, 4, 0, 1, 1.0, + # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + # cylinderCentralPath.minorRadii[0]) + # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, + # cylinderShape=cylinderShape, + # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) + + # joining_torso = JoiningTorso([4, 4, 1]) + # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) + # print(joining_torso.nodeId) + # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) + # + # + # torso_part = torso_cylinder._shield + + +# -4.990e+00, -7.830e-01, 5.4884e+00 +# +# +# +# -6.480e+00, 1.118e-01, 3.8448e+00 +# +# -4.947e+00, 1.216e-01, 5.4829e+00 +# +# -6.004e+00, -6.005e-01, 3.3709e+00 +#-6.031e+00, 9.325e-02, 3.393e+00 + +# -6.496e+00, -5.925e-01, 3.8599e+00 + + # -6.031e+00, 9.325e-02, 3.393e+00 + + # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], + # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], + # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], + # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] + + # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) + # + # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) + # + # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], + # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], + # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], + # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] + # + # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], + # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], + # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], + # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] + # + # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) + # shoulder_part2._shoulder = True + # + # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) + # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) + # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) + # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) + # + # joining_box = JoiningBox([1, 4, 1]) + # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box) + + + + + # elementsCount = [2, 2, 5] + # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] + # + # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], + # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], + # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] + # + # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], + # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] + # + # + # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) + # self.copyBaseLeg2Bifurcation(baseleg1, 1) + # + # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] + # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] + # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] + # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] + # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] + # + # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) + # self.copyBaseLeg2Bifurcation(baseleg2, 2) + + # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + + def _get_node_params(self): + """ + + :return: + """ + x_bottom_base_centre = [0.0, 0.0, 0.0] + x_bottom_base_curve1w = [self.torso_radius, 0.0, 0.0] + x_bottom_base_curve1e = [-self.torso_radius, 0.0, 0.0] + x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] + d1_bottom_base_curve1 = [[self.torso_radius/self._elementsCount[0], 0.0, 0.0], + [self.torso_radius/self._elementsCount[0], 0.0, 0.0], + [self.torso_radius/self._elementsCount[0], 0.0, 0.0]] + d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + x_bottom_end_centre = [0.0, 0.0, 1.4] + x_bottom_end_curve1w = [1.2, 0.0, 1.0] + x_bottom_end_curve1e = [-1.2, 0.0, 1.0] + x_bottom_end_curve2 = [0.0, 1.0, 1.4] + d1_bottom_end_curve1 = [[0.5*0.7071, 0.0, 0.5*0.7071], + [1/self._elementsCount[0], 0.0, 0.0], + [0.5*0.7071, 0.0, -0.5*0.7071]] + d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], + [0.0, 1/self._elementsCount[1], 0.0]] + + nodeparams1 = [[x_bottom_base_curve1e, x_bottom_base_centre, x_bottom_base_curve1w, x_bottom_base_curve2, d1_bottom_base_curve1, + d1_bottom_base_curve2], + [x_bottom_end_curve1e, x_bottom_end_centre, x_bottom_end_curve1w, x_bottom_end_curve2, d1_bottom_end_curve1, + d1_bottom_end_curve2]] + + # x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] + # x_shoulder_base_curve1 = [1.2, 0.0, 1.0] + # x_shoulder_base_curve2 = [0.75, 1.0, self.shoulder_height] + # d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] + # d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + x_shoulder_base_centre = self.shoulder_joint + x_shoulder_base_curve1w = self.armpit + x_shoulder_base_curve1e = self.shoulder_point + x_shoulder_base_curve2 = [self.shoulder_joint[0], 1.0, self.shoulder_joint[2]] + derivw = vector.addVectors([x_shoulder_base_curve1w, x_shoulder_base_centre], [1, -1]) + derive = vector.addVectors([x_shoulder_base_centre, x_shoulder_base_curve1e], [1, -1]) + derivc = vector.addVectors([derivw, derive], [1, 1]) + derivc = vector.scaleVector(derivc, 0.5) + d1_shoulder_base_curve1 = [derive, derivc, derivw] + d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + kv = [0.0, 1.0, 0.0] + cv = [self.right_arm_length, 0.0, 0.0] + cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) + # ce = vector.addVectors([cev, [0.0, 0.0, self.shoulder_height]], [1, 1]) + ce = vector.addVectors([cev, self.shoulder_joint], [1, 1]) + x_shoulder_end_centre = ce + # x_shoulder_end_curve1 = [1.7, 0.0, self.shoulder_height - self.left_arm_radius] + x_shoulder_end_curve1w = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) + x_shoulder_end_curve1e = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), -self.right_arm_radius)], [1, 1]) + # x_shoulder_end_curve2 = [1.7, self.left_arm_radius, self.shoulder_height] + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) + d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] + + nodeparams2 = [[x_shoulder_base_curve1e, x_shoulder_base_centre, x_shoulder_base_curve1w, x_shoulder_base_curve2, d1_shoulder_base_curve1, + d1_shoulder_base_curve2], + [x_shoulder_end_curve1e, x_shoulder_end_centre, x_shoulder_end_curve1w, x_shoulder_end_curve2, d1_shoulder_end_curve1, + d1_shoulder_end_curve2]] + + return nodeparams1, nodeparams2 + + def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): + """ + + :param joining_torso: + :param shoulder_part: + :param bottom_part: + :return: + """ + for n2 in range(joining_torso._elementsCount[1] + 1): + for n1 in range(joining_torso._elementsCount[1] + 1): + joining_torso.nodeId[1][n2][n1] = torso.nodeId[0][n2][4 - n1] + joining_torso.px[1][n2][n1] = torso.px[0][n2][4 - n1] + joining_torso.pd1[1][n2][n1] = torso.pd1[0][n2][4 - n1] + joining_torso.pd2[1][n2][n1] = torso.pd2[0][n2][4 - n1] + joining_torso.pd3[1][n2][n1] = torso.pd3[0][n2][4 - n1] + + if n1 <= joining_torso._elementsCount[0]//2: + joining_torso.nodeId[0][n2][n1] = shoulder_joint.nodeId[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.px[0][n2][n1] = shoulder_joint.px[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd1[0][n2][n1] = shoulder_joint.pd1[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd2[0][n2][n1] = shoulder_joint.pd2[0][n2][joining_torso._elementsCount[0] - n1] + joining_torso.pd3[0][n2][n1] = shoulder_joint.pd3[0][n2][joining_torso._elementsCount[0] - n1] + else: + joining_torso.nodeId[0][n2][n1] = bottom_joint.nodeId[1][n2][n1] + joining_torso.px[0][n2][n1] = bottom_joint.px[1][n2][n1] + joining_torso.pd1[0][n2][n1] = bottom_joint.pd1[1][n2][n1] + joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] + joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] + + def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): + """ + + :param shoulder_connecting_to_box: + :param joining_box: + :param shoulder_part: + :return: + """ + for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): + for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): + shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] + shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd2[cidxs[0]][n2][n1] = cylinder_part.pd2[cidxs[1]][n2][n1] + shoulder_connecting_to_box.pd3[cidxs[0]][n2][n1] = cylinder_part.pd3[cidxs[1]][n2][n1] + + shoulder_connecting_to_box.nodeId[bidx][n2][2] = joining_box.nodeId[1][n2][1] + shoulder_connecting_to_box.px[bidx][n2][2] = joining_box.px[1][n2][1] + shoulder_connecting_to_box.pd1[bidx][n2][2] = joining_box.pd1[1][n2][1] + shoulder_connecting_to_box.pd2[bidx][n2][2] = joining_box.pd2[1][n2][1] + shoulder_connecting_to_box.pd3[bidx][n2][2] = joining_box.pd3[1][n2][1] + + def join_box_to_bottom_and_shoulder(self, joining_box, bottom_part, shoulder_part): + """ + + :param bottom_part: + :param shoulder_part: + :return: + """ + + for n2 in range(bottom_part._elementsCount[1] + 1): + for n1 in range(2): + joining_box.nodeId[0][n2][n1] = bottom_part.nodeId[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.px[0][n2][n1] = bottom_part.px[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd1[0][n2][n1] = bottom_part.pd1[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd2[0][n2][n1] = bottom_part.pd2[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.pd3[0][n2][n1] = bottom_part.pd3[bottom_part._elementsCount[2]][n2][n1 + 1] + joining_box.nodeId[1][n2][0] = shoulder_part.nodeId[0][n2][2] + joining_box.px[1][n2][0] = shoulder_part.px[0][n2][2] + joining_box.pd1[1][n2][0] = shoulder_part.pd1[0][n2][2] + joining_box.pd2[1][n2][0] = shoulder_part.pd2[0][n2][2] + joining_box.pd3[1][n2][0] = shoulder_part.pd3[0][n2][2] + + def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + def condition(n2, n1): + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if condition(n2, n1): + shoulder_part.px[n3][n2][n1] = None + shoulder_part.pd1[n3][n2][n1] = None + shoulder_part.pd2[n3][n2][n1] = None + shoulder_part.pd3[n3][n2][n1] = None + + + def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): + """ + + :param shoulder_part: + :param bottom_part: + :return: + """ + def condition(n2, n1): + # if c: + # n2, n1 = n1, n2 + # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ + # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) + if c: + return n2 == 0 or n2 == 1 + else: + return n1 == 0 or n1 == 1 + + def index(n2, n1): + if c: + if n2 == 0 and n1 == 1: + return n1 - 1, 4 - n2 - 1 + if n2 == 0 and n1 == 3: + return n1 + 1, 4 - n2 - 1 + else: + return n1, 4 - n2 + else: + return n2, n1 + + for n3 in range(1): + for n2 in range(shoulder_part._elementsCount[0] + 1): + for n1 in range(shoulder_part._elementsCount[1] + 1): + if condition(n2, n1): + n2b, n1b = index(n2, n1) + n3b = bottom_part._elementsCount[2] + shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2b][n1b] + shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2b][n1b] + shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2b][n1b] + shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] + shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] + + # def copyBaseLeg2Bifurcation(self, baseleg, idx): + # """ + # + # :return: + # """ + # for n3 in range(self._elementsCount[2]//2 + 1): + # for n2 in range(self._elementsCount[0] + 1): + # for n1 in range(self._elementsCount[1] + 1): + # if idx == 1: + # n3s = n3 + # elif idx == 2: + # n3s = self._elementsCount[2]//2 + 2 + n3 + # self.px[n3s][n2][n1] = baseleg.px[n3][n2][n1] + # self.pd1[n3s][n2][n1] = baseleg.pd1[n3][n2][n1] + # self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] + # self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] + # if idx == 2 and n3 == 0: + # if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): + # self.px[n3s][n2][n1] = None + # self.pd1[n3s][n2][n1] = None + # self.pd2[n3s][n2][n1] = None + # self.pd3[n3s][n2][n1] = None + + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): + """ + Create cylinder nodes from coordinates. + :param nodes: nodes from coordinates. + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + self._startNodeIdentifier = nodeIdentifier + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) + self._endNodeIdentifier = nodeIdentifier + + def generateElements(self, mesh, fieldModule, coordinates, part_structure): + """ + Create cylinder elements from nodes. + :param mesh: + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + self._startElementIdentifier = elementIdentifier + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + self._endElementIdentifier = elementIdentifier + + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): + """ + Create shield nodes from coordinates. + """ + nodeIdentifier = startNodeIdentifier + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) + cache = fieldmodule.createFieldcache() + + for n3 in range(part_structure._elementsCount[2] + 1): + for n2 in range(part_structure._elementsCount[1] + 1): + for n1 in range(part_structure._elementsCount[0] + 1): + if part_structure.px[n3][n2][n1]: + node = nodes.createNode(nodeIdentifier, nodetemplate) + part_structure.nodeId[n3][n2][n1] = nodeIdentifier + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + nodeIdentifier += 1 + + return nodeIdentifier + + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, 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 meshGroups: Zinc mesh groups to add elements to. + :return: next elementIdentifier. + """ + elementIdentifier = startElementIdentifier + useCrossDerivatives = False + mesh = fieldmodule.findMeshByDimension(3) + + tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) + eft = tricubichermite.createEftNoCrossDerivatives() + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) + elementtemplate.defineField(coordinates, -1, eft) + + elementtemplate1 = mesh.createElementtemplate() + elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) + + # isEven = (self.elementsCountAcross % 2) == 0 + e1a = 0 + e1b = e1a + 1 + e1z = part_structure._elementsCount[0] - 1 + e1y = e1z - 1 + e2a = 0 + e2b = e2a + 1 + e2c = e2a + 2 + e2z = part_structure._elementsCount[1]-1 + e2y = e2z - 1 + # e2x = e2z - 2 + for e3 in range(part_structure._elementsCount[2]): + for e2 in range(part_structure._elementsCount[1]): + for e1 in range(part_structure._elementsCount[0]): + eft1 = eft + scalefactors = None + # if e3 >= 3: + # e3t = e3 + 1 + # else: + # e3t = e3 + # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], + # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], + # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], + # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] + nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + + if isinstance(part_structure, JoiningBox): + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2a or e2 == e2z: + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: + # e3r = e3t-1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + + # if e3 == 2: + # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # elif e3 == 3: + # if e1 == e1b: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + if isinstance(part_structure, BaseLeg2): + if part_structure._shoulder: + if e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # else: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + + # else: + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + # if e3 != 2: + # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if isinstance(part_structure, BaseLeg2): + if part_structure._shoulder and e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*part_structure._elementsCount[1] - e1-1 + nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + 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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.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] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e1 > e1z: + e2r = part_structure._elementsCount[0] - e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = part_structure.nodeId[e3][e2r][e1z] + nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + # if e3 == part_structure._elementsCount[2] // 2 + 1: + # e3r = e3 - 1 + # nids[0] = part_structure.nodeId[e3r][e2][e1] + # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # if e3 == 2: + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + + + + + + else: + if e1 < e1a: + nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) + + # if e3 == 2: + # if e1 == e1b: + # # joining elements + # if e2 == 0: + # nids = [15, 17, 22, 24, 16, 18, 23, 25] + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + + + + + # elif e2 == 1: + # nids = [17, 20, 24, 26, 18, 21, 25, 27] + + if not all(nids): + continue + + if eft1 is not eft: + elementtemplate1.defineField(coordinates, -1, eft1) + element = mesh.createElement(elementIdentifier, elementtemplate1) + else: + element = mesh.createElement(elementIdentifier, elementtemplate) + result2 = element.setNodesByIdentifier(eft1, nids) + if scalefactors: + result3 = element.setScaleFactors(eft1, scalefactors) + else: + result3 = 7 + #print('create element shield', elementIdentifier, result2, result3, nids) + part_structure.elementId[e3][e2][e1] = elementIdentifier + elementIdentifier += 1 + + for meshGroup in meshGroups: + meshGroup.addElement(element) + + return elementIdentifier + + +class BaseLeg: + """ + Base case for creating a child + """ + def __init__(self, elementsCount, nodeparams): + """ + + :param fieldmodule: + :param coordinates: + :param mesh: + :param nodes: + """ + elementsCount = [4, 4, 2] + self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] + self.nodeparams = nodeparams + self._shoulder = False + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.generateBaseLeg(nodeparams) + + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1): + n3q = n3 + n2q = elementsCount[1] - n2 + n1q = n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + + n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + plane = [n[0], n[1], n[2], d] + mirror = Mirror(plane) + for n2 in range(elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): + n3q = n3 + n2q = n2 + n1q = elementsCount[0] - n1 + if self.px[n3q][n2q][n1q]: + self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: + self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + else: + self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) + self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) + self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self._elementsCount = elementsCount + + def generateBaseLeg(self, nodeparams): + """ + Generate base leg that is a cylinder generated from cylinder ends. + :return: + """ + bottomnodeparams = nodeparams[0] + topnodeparams = nodeparams[1] + self.genetateBottomSurface(bottomnodeparams) + self.generateTopSurface(topnodeparams) + self.generateMiddleLevels() + self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateMiddleLevels() + # self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + def genetateBottomSurface(self, bottomnodeparams): + """ + Use major and minor curves to generate the ellipse + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, 0) + + def generateTopSurface(self, topnodeparams): + """ + + :return: + """ + centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] + txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + + def generateMiddleLevels(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # generate the armpit curves. + elementsCountOut = 2 + txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], + btx[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [btd2[0][self._elementsCount[1]][self._elementsCount[0]], + btd2[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + elementsCountOut) + txec1, td1ec1, pec1, pxic1, psfc1 = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][0], btx[self._elementsCount[2]][self._elementsCount[1]][0]], + [btd2[0][self._elementsCount[1]][0], btd2[self._elementsCount[2]][self._elementsCount[1]][0]], + elementsCountOut) + txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]], btx[self._elementsCount[2]][0][self._elementsCount[0]]], + [btd2[0][0][self._elementsCount[0]], btd2[self._elementsCount[2]][0][self._elementsCount[0]]], + elementsCountOut) + + tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][self._elementsCount[0]], + btd3[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]][self._elementsCount[0]], + btd1[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlec1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][0], + btd3[self._elementsCount[2]][self._elementsCount[1]][0]], + [[0.0, 0.0, 0.0]] * 2, pec1, pxic1, psfc1)[0] + tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]], + btd3[self._elementsCount[2]][0][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] + + for n3 in range(1, self._elementsCount[2]): + centre = txcc1[n3] + txc1, td1c1 = self.generate1DPath([centre, txec1[n3]], [[-c for c in tdlcc1[n3]], tdlec1[n3]], self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, n3) + + def smoothd2(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # smooth d2 + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + nx = [] + nd1 = [] + for n3 in range(self._elementsCount[2] + 1): + nx.append(btx[n3][n2][n1]) + nd1.append(btd2[n3][n2][n1]) + td2 = smoothCubicHermiteDerivativesLine(nx, nd1) + for n3 in range(self._elementsCount[2] + 1): + btd2[n3][n2][n1] = td2[n3] + + def generate1DPath(self, nx, nd1, elementsCountOut): + """ + Given end nodes generate 1d path + :return: + """ + tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) + return tx, td1 + + def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): + """ + Get major and minor curves to generate the rounded surface. + :return: + """ + + # self._coreMinorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) + # self._coreMajorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) + + # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 + # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] + # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] + majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] + minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] + elementsCountAcrossShell = 0 + elementsCountAcrossTransition = 1 + shellProportion = 1.0 + coreMajorRadius = 1.0 + coreMinorRadius = 1.0 + elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 + ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + shield = ellipse.getShield() + ellipse.generateBase1DMesh(0) + + ellipse.px[self._elementsCount[1]][0] = txc1[-1] + ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] + ellipse.px[0][self._elementsCount[0]] = txc2[-1] + ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] + + nx = [] + nd1 = [] + for n in range(elementsCountAround + 1): + n1, n2 = shield.convertRimIndex(n) + xi = n/elementsCountAround + # ellipse.px[n2][n1][2] = (1 - xi) * ellipse.px[self._elementsCount[1]][0][2] + xi * \ + # ellipse.px[0][self._elementsCount[0]][2] + x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), + vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) + delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) + delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) + delta_p_normalmag = vector.dotproduct(delta_p, normal) + delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) + delnormag = vector.dotproduct(delta, normal) + delnor = vector.scaleVector(normal, delnormag) + if 0 0), 'createCylinderMesh3d: Invalid number of along elements' + # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' + # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ + # ' is not an even number' + # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' + # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, + # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ + # 'createCylinderMesh3d: Invalid cylinder mode.' + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + mesh = fieldmodule.findMeshByDimension(3) + + +class CrotchEllipses: + def __init__(self): + """ + + """ + + +class BaseLeg2: + """ + Base case for creating a child + """ + def __init__(self, elementsCount, nodeparams): + """ + + :param fieldmodule: + :param coordinates: + :param mesh: + :param nodes: + """ + # elementsCount = [4, 4, 3] + # self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] + self._elementsCount = [elementsCount[0], elementsCount[1], elementsCount[2]] + self.nodeparams = nodeparams + self._shoulder = False + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.generateBaseLeg(nodeparams) + + # n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + # plane = [n[0], n[1], n[2], d] + # mirror = Mirror(plane) + # for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): + # for n3 in range(elementsCount[2]+1): + # for n1 in range(elementsCount[0]//2+1): + # n3q = n3 + # n2q = elementsCount[1] - n2 + # n1q = n1 + # if self.px[n3q][n2q][n1q]: + # self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + # self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + # self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + # self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + # + # n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + # plane = [n[0], n[1], n[2], d] + # mirror = Mirror(plane) + # for n2 in range(elementsCount[1]+1): + # for n3 in range(elementsCount[2]+1): + # for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): + # n3q = n3 + # n2q = n2 + # n1q = elementsCount[0] - n1 + # if self.px[n3q][n2q][n1q]: + # self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) + # if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: + # self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) + # self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) + # else: + # self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) + # self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) + # self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + self._elementsCount = elementsCount + + def generateBaseLeg(self, nodeparams): + """ + Generate base leg that is a cylinder generated from cylinder ends. + :return: + """ + bottomnodeparams = nodeparams[0] + topnodeparams = nodeparams[1] + self.genetateBottomSurface(bottomnodeparams) + self.generateTopSurface(topnodeparams) + self.generateMiddleLevels() + self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], + # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) + # self.generateMiddleLevels() + # self.smoothd2() + + # self.generateNodes(nodes, fieldmodule, coordinates) + # self.generateElements(mesh, fieldmodule, coordinates) + + def genetateBottomSurface(self, bottomnodeparams): + """ + Use major and minor curves to generate the ellipse + :return: + """ + xec1e, centre, xec1w, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4], bottomnodeparams[5] + txc1, td1c1 = self.generate1DPath([xec1e, centre, xec1w], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]//2) + # txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + # txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, 0) + + def generateTopSurface(self, topnodeparams): + """ + + :return: + """ + xec1e, centre, xec1w, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4], topnodeparams[5] + txc1, td1c1 = self.generate1DPath([xec1e, centre, xec1w], d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]//2) + # txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) + # txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + + def generateMiddleLevels(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # generate the armpit curves. + elementsCountOut = self._elementsCount[2] + txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][self._elementsCount[0]//2], + btx[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], + [btd2[0][self._elementsCount[1]//2][self._elementsCount[0]//2], + btd2[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], + elementsCountOut) + txec1w, td1ec1w, pec1w, pxic1w, psfc1w = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][0], btx[self._elementsCount[2]][self._elementsCount[1]//2][0]], + [btd2[0][self._elementsCount[1]//2][0], btd2[self._elementsCount[2]][self._elementsCount[1]//2][0]], + elementsCountOut) + txec1e, td1ec1e, pec1e, pxic1e, psfc1e = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][self._elementsCount[0]], btx[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], + [btd2[0][self._elementsCount[1]//2][self._elementsCount[0]], btd2[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], + elementsCountOut) + txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]//2], btx[self._elementsCount[2]][0][self._elementsCount[0]//2]], + [btd2[0][0][self._elementsCount[0]//2], btd2[self._elementsCount[2]][0][self._elementsCount[0]//2]], + elementsCountOut) + + tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][self._elementsCount[0]//2], + btd3[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]//2][self._elementsCount[0]//2], + btd1[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], + [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] + tdlec1w = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][0], + btd3[self._elementsCount[2]][self._elementsCount[1]//2][0]], + [[0.0, 0.0, 0.0]] * 2, pec1w, pxic1w, psfc1w)[0] + tdlec1e = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][self._elementsCount[0]], + btd3[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], + [[0.0, 0.0, 0.0]] * 2, pec1e, pxic1e, psfc1e)[0] + tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]//2], + btd3[self._elementsCount[2]][0][self._elementsCount[0]//2]], + [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] + + for n3 in range(1, self._elementsCount[2]): + centre = txcc1[n3] + txc1, td1c1 = self.generate1DPath([txec1e[n3], centre, txec1w[n3]], [[-c for c in tdlec1e[n3]], [-c for c in tdlcc1[n3]], tdlec1w[n3]], self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]//2) + ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) + self.copyEllipseNodesToBifurcation(ellipse, n3) + + def smoothd2(self): + """ + + :return: + """ + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + # smooth d2 + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + nx = [] + nd1 = [] + for n3 in range(self._elementsCount[2] + 1): + nx.append(btx[n3][n2][n1]) + nd1.append(btd2[n3][n2][n1]) + td2 = smoothCubicHermiteDerivativesLine(nx, nd1) + for n3 in range(self._elementsCount[2] + 1): + btd2[n3][n2][n1] = td2[n3] + + def generate1DPath(self, nx, nd1, elementsCountOut): + """ + Given end nodes generate 1d path + :return: + """ + tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut, arcLengthDerivatives = True) + return tx, td1 + + def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): + """ + Get major and minor curves to generate the rounded surface. + :return: + """ + + # self._coreMinorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) + # self._coreMajorRadii.append( + # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) + + # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 + # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] + # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] + majorAxis = [c*(self._elementsCount[0]//2) for c in td1c2[0]] + minorAxis = [-c*(self._elementsCount[1]//2) for c in td1c1[self._elementsCount[1]//2]] + elementsCountAcrossShell = 0 + elementsCountAcrossTransition = 1 + shellProportion = 1.0 + coreMajorRadius = 1.0 + coreMinorRadius = 1.0 + # elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 + elementsCountAround = 2*(self._elementsCount[0]//2 + self._elementsCount[1]//2 - 2) + # ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + # elementsCountAcrossShell, elementsCountAcrossTransition, + # shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + ellipse = Ellipse2D(centre, majorAxis, minorAxis, self._elementsCount[0], self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + shield = ellipse.getShield() + ellipse.generateBase1DMesh(0) + + # Modify nodes around the ellipse. + ellipse.px[self._elementsCount[1]//2][0] = txc1[-1] + ellipse.pd3[self._elementsCount[1]//2][0] = td1c1[-1] + ellipse.px[self._elementsCount[1]//2][self._elementsCount[0]] = txc1[0] + ellipse.pd3[self._elementsCount[1]//2][self._elementsCount[0]] = vector.scaleVector(td1c1[0], -1) + ellipse.px[0][self._elementsCount[0]//2] = txc2[-1] + ellipse.pd3[0][self._elementsCount[0]//2] = td1c2[-1] + + normal = vector.normalise(vector.crossproduct3(td1c1[self._elementsCount[1]//2], td1c2[0])) + + nx = [] + nd1 = [] + for n in range(elementsCountAround + 1): + n1, n2 = shield.convertRimIndex(n) + if n <= elementsCountAround // 2: + nq = n + point1 = txc1[-1] + point2 = txc2[-1] + else: + nq = n - elementsCountAround//2 + point1 = txc2[-1] + point2 = txc1[0] + delta_p_normal = self.point_displacement(nq, centre, point1, point2, elementsCountAround//2, normal) + if 0 < nq < elementsCountAround//2: + ellipse.px[n2][n1] = vector.addVectors([ellipse.px[n2][n1], delta_p_normal], [1, 1]) + nx.append(ellipse.px[n2][n1]) + nd1.append(ellipse.pd1[n2][n1]) + td1 = smoothCubicHermiteDerivativesLine(nx, nd1) + for n in range(1, elementsCountAround): + n1, n2 = shield.convertRimIndex(n) + ellipse.pd1[n2][n1] = td1[n] + + # Create internal nodes and mirror to get the other half. + ellipse.setRimNodes() + rscx, rscd1, rscd2, rscd3 = ellipse.createMirrorCurve() + ellipse.createRegularRowCurves(ellipse.px[:self._elementsCount[1]//2+1][self._elementsCount[0]//2], rscd1, rscd3) + ellipse.createRegularColumnCurves() + shield.getTriplePoints(0) + ellipse.smoothTriplePointsCurves() + ellipse.smoothTransitionRims() + if ellipse.ellipseShape == EllipseShape.Ellipse_SHAPE_FULL: + ellipse.generateNodesForUpperHalf() + + # smooth triple1 + nx = [ellipse.px[1][1], ellipse.px[0][1]] + nd1 = [[-ellipse.pd1[1][1][c]-ellipse.pd3[1][1][c] for c in range(3)], ellipse.pd3[0][1]] + td3 = smoothCubicHermiteDerivativesLine(nx, nd1) + + ellipse.pd3[0][1] = td3[1] + + # Calculate d2. + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if ellipse.px[n2][n1]: + ellipse.pd2[n2][n1] = vector.crossproduct3(ellipse.pd3[n2][n1], ellipse.pd1[n2][n1]) + + return ellipse + + def copyEllipseNodesToBifurcation(self, ellipse, n3): + """ + Copy ellipse nodes to bifurcation + :param ellipse: + :return: + """ + + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + n2e, n1e = n2, n1 + self.px[n3][n2][n1] = ellipse.px[n2e][n1e] + self.pd1[n3][n2][n1] = ellipse.pd1[n2e][n1e] + self.pd2[n3][n2][n1] = ellipse.pd2[n2e][n1e] + self.pd3[n3][n2][n1] = ellipse.pd3[n2e][n1e] + + # def warp_ellipse(self, centre, point1, point2, elementsCountAround, shield, ellipse): + # """ + # + # :return: + # """ + # + # + # ellipse.px[self._elementsCount[1] // 2][0] = txc1[-1] # point1 + # ellipse.pd3[self._elementsCount[1] // 2][0] = td1c1[-1] # point1d3 + # ellipse.px[0][self._elementsCount[0] // 2] = txc2[-1] # point2 + # ellipse.pd3[0][self._elementsCount[0] // 2] = td1c2[-1] # point2d3 + # + # # centre = ellipse.px[self._elementsCount[1] // 2][self._elementsCount[0] // 2] + # # point1 = ellipse.px[self._elementsCount[1] // 2][0] + # # point2 = ellipse.px[0][self._elementsCount[0] // 2] + # normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) + # delta = [point1[c] - point2[c] for c in range(3)] + # + # nx = [] + # nd1 = [] + # for n in range(elementsCountAround + 1): + # delta_p_normal = self.point_displacement(n, centre, point1, point2, elementsCountAround, normal) + # + # # Modify points around the ellipse. Warp it. + # n1, n2 = shield.convertRimIndex(n) + # if 0 < n < elementsCountAround: + # ellipse.px[n2][n1] = vector.addVectors([ellipse.px[n2][n1], delta_p_normal], [1, 1]) + # nx.append(ellipse.px[n2][n1]) + # nd1.append(ellipse.pd1[n2][n1]) + # td1 = smoothCubicHermiteDerivativesLine(nx, nd1) + + def point_displacement(self, n, centre, point1, point2, elementsCountAround, normal): + """ + :param normal: unit normal vector of an ellipse in centre. + :return: displacement vector for a node on the ellipse between point1 and point2. + """ + xi = n / elementsCountAround + x_p = vector.addVectors([vector.scaleVector(point1, 1 - xi), vector.scaleVector(point2, xi)], [1, 1]) + + delta_p = vector.addVectors([x_p, centre], [1, -1]) + delta_p_normalmag = vector.dotproduct(delta_p, normal) + delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) + + return delta_p_normal \ No newline at end of file From 29aa0fcf9705b1e2c45e7c408a28f24de02ad17a Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 24 Feb 2022 11:27:34 +1300 Subject: [PATCH 12/38] changed the armpit --- src/scaffoldmaker/utils/bifurcation3d2.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 427244fa..823758e8 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -176,6 +176,7 @@ def _get_node_params(self): :return: """ + armpit = [1.2, 0.0, 1.0] x_bottom_base_centre = [0.0, 0.0, 0.0] x_bottom_base_curve1 = [self.torso_radius, 0.0, 0.0] x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] @@ -184,7 +185,7 @@ def _get_node_params(self): d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], [0.0, 1/self._elementsCount[1], 0.0]] x_bottom_end_centre = [0.0, 0.0, 1.4] - x_bottom_end_curve1 = [1.2, 0.0, 1.0] + x_bottom_end_curve1 = armpit x_bottom_end_curve2 = [0.0, 1.0, 1.4] d1_bottom_end_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]] @@ -197,7 +198,7 @@ def _get_node_params(self): d1_bottom_end_curve2]] x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] - x_shoulder_base_curve1 = [1.2, 0.0, 1.0] + x_shoulder_base_curve1 = armpit x_shoulder_base_curve2 = [0.75, 1.0, self.shoulder_height] d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] @@ -218,9 +219,9 @@ def _get_node_params(self): [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, d1_shoulder_end_curve2]] - x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] - x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] - x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] + x_shoulder_base_centre = [-0.75, 0.0, self.shoulder_height] + x_shoulder_base_curve2 = [-armpit[0], armpit[1], armpit[2]] + x_shoulder_base_curve1 = [-0.75, 1.0, self.shoulder_height] d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] From 7fa105c380b6a59e41e39f86e05c834cae1deab1 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 24 Mar 2022 16:40:04 +1300 Subject: [PATCH 13/38] Make half ellipse of the arm flat. --- src/scaffoldmaker/utils/bifurcation3d2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 823758e8..de37b25d 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -211,7 +211,9 @@ def _get_node_params(self): x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) # x_shoulder_end_curve2 = [1.7, self.left_arm_radius, self.shoulder_height] x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) - d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] + # d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1]), + vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1])] d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] nodeparams2 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, From 7800a4733c9de8568dd9964a9f26289b058daf0a Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 1 Apr 2022 01:39:09 +1300 Subject: [PATCH 14/38] Add range of elements along cylinder parameter. Add arms,neck and head. --- .../meshtype_3d_solidbifurcation2.py | 51 +- src/scaffoldmaker/utils/bifurcation3d2.py | 455 +++++++++++++++++- src/scaffoldmaker/utils/cylindermesh.py | 21 +- src/scaffoldmaker/utils/shieldmesh.py | 20 +- 4 files changed, 522 insertions(+), 25 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 6355f4e9..9c5b31f8 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -64,19 +64,36 @@ def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] options = { 'Central path': copy.deepcopy(centralPathOption), - 'Armpit': [1.3, 0.0, 1.4], + 'Armpit': [1.2, 0.0, 1.0], 'Torso radius': 1.0, 'Left arm radius': 1.0, 'Right arm radius': 1.0, 'Neck radius': 0.8, + 'Neck radius 2': 0.8, + 'Neck length': 0.4, + 'Neck number of elements': 2, 'Neck shoulder point': [0.7, 0.0, 2.8], + 'Head length': 1.0, + 'Head number of elements': 5, + 'Head radius': 1.0, 'Shoulder height': 2.2, 'Shoulder joint': [1.1, 0.0, 2.4], 'Shoulder point': [1.0, 0.0, 2.8], 'Shoulder start': [0.5, 0.0, 2.2], 'Neck height': 3.6, 'Right arm angle': 0.0, +<<<<<<< HEAD 'Right arm length': 1.7, +======= + 'Left arm angle': 0.0, + 'Right shoulder length': 0.95, + 'Right arm length': 2.0, + 'Right arm number of elements': 5, + 'Right wrist radius': 0.8, + 'Lower torso length': 5.5, + 'Lower torso number of elements': 4, + 'Lower torso radii': [1.3, 1.0], +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) 'Number of elements across major': 4, 'Number of elements across minor': 4, 'Number of elements across shell': 0, @@ -100,14 +117,27 @@ def getOrderedOptionNames(): 'Left arm radius', 'Right arm radius', 'Neck radius', + 'Neck radius 2', + 'Neck length', + 'Neck number of elements', 'Neck shoulder point', + 'Head length', + 'Head number of elements', + 'Head radius', 'Shoulder joint', 'Shoulder height', 'Shoulder point', 'Shoulder start', 'Neck height', 'Right arm angle', + 'Left arm angle', + 'Right shoulder length', 'Right arm length', + 'Right arm number of elements', + 'Right wrist radius', + 'Lower torso length', + 'Lower torso number of elements', + 'Lower torso radii', 'Number of elements across major', 'Number of elements across minor', 'Number of elements across shell', @@ -221,20 +251,37 @@ def generateBaseMesh(region, options): left_arm_radius = options['Left arm radius'] right_arm_radius = options['Right arm radius'] neck_radius = options['Neck radius'] + neck_radius2 = options['Neck radius 2'] + neck_length = options['Neck length'] + neck_number_of_elements = options['Neck number of elements'] shoulder_height = options['Shoulder height'] neck_height = options['Neck height'] right_arm_angle = options['Right arm angle'] + left_arm_angle = options['Left arm angle'] + right_shoulder_length = options['Right shoulder length'] right_arm_length = options['Right arm length'] + rightArmNumberOfElements = options['Right arm number of elements'] + righ_wrist_radius = options['Right wrist radius'] shoulder_joint = options['Shoulder joint'] armpit = options['Armpit'] neck_shoulder = options['Neck shoulder point'] shoulder_point = options['Shoulder point'] shoulder_start = options['Shoulder start'] + head_length = options['Head length'] + head_number_of_elements = options['Head number of elements'] + head_radius = options['Head radius'] + lower_torso_length = options['Lower torso length'] + lower_torso_number_of_elements = options['Lower torso number of elements'] + lower_torso_radii = options['Lower torso radii'] # bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, # neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length, # shoulder_joint, armpit, neck_shoulder, shoulder_point, shoulder_start) bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, - neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length) + neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, + right_shoulder_length, right_arm_length, rightArmNumberOfElements, + righ_wrist_radius, neck_radius2, neck_length, neck_number_of_elements, + head_length, head_number_of_elements, head_radius, armpit, lower_torso_length, + lower_torso_number_of_elements, lower_torso_radii) annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index de37b25d..9bf7d0f7 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -19,7 +19,11 @@ from opencmiss.zinc.element import Element from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.utils.derivativemoothing import DerivativeSmoothing from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues +from scaffoldmaker.utils.spheremesh import SphereMesh, SphereShape +from scaffoldmaker.utils.shieldmesh import ShieldMesh3D + class BifurcationMesh: @@ -28,7 +32,10 @@ class BifurcationMesh: """ def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, - shoulder_height, neck_height, right_arm_angle, right_arm_length): + shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, + right_arm_length, rightArmNumberOfElements, righ_wrist_radius, neck_radius2, neck_length, + neck_number_of_elements, head_length, head_number_of_elements, head_radius, armpit, + lower_torso_length, lower_torso_number_of_elements, lower_torso_radii): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -42,10 +49,24 @@ def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radi self.left_arm_radius = left_arm_radius self.right_arm_radius = right_arm_radius self.neck_radius = neck_radius + self.neck_radius2 = neck_radius2 + self.neck_length = neck_length + self.head_length = head_length + self.head_number_of_elements = head_number_of_elements + self.head_radius = head_radius + self.neck_number_of_elements = neck_number_of_elements self.shoulder_height = shoulder_height self.neck_height = neck_height self.right_arm_angle = right_arm_angle + self.left_arm_angle = left_arm_angle + self.right_shoulder_length = right_shoulder_length self.right_arm_length = right_arm_length + self.rightArmNumberOfElements = rightArmNumberOfElements + self.righ_wrist_radius = righ_wrist_radius + self.armpit = armpit + self.lower_torso_length = lower_torso_length + self.lower_torso_number_of_elements = lower_torso_number_of_elements + self.lower_torso_radii = lower_torso_radii self.createBifurcationMesh3d(fieldModule, coordinates) @@ -70,27 +91,31 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): nodeparams1, nodeparams2, nodeparams3, nodeparams4 = self._get_node_params() - bottom_part = BaseLeg(self._elementsCount, nodeparams1) - self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) - self.generateElements(mesh, fieldmodule, coordinates, bottom_part) + torso_upper_part = BaseLeg(self._elementsCount, nodeparams1) + self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) + self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) +<<<<<<< HEAD shoulder_part = BaseLeg(self._elementsCount, nodeparams2) +======= + shoulder_part = BaseLeg(self._elementsCount, nodeparams2, shoulder_right=True) +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) shoulder_part._shoulder = True self.remove_duplicate_nodes_from_shoulder(shoulder_part) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) + self.join_shoulder_to_bottom_part(shoulder_part, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) joining_box = JoiningBox([1, 4, 1], self.shoulder_height) self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) + self.join_box_to_bottom_and_shoulder(joining_box, torso_upper_part, shoulder_part) self.generateElements(mesh, fieldmodule, coordinates, joining_box) - shoulder_part_left = BaseLeg(self._elementsCount, nodeparams3) + shoulder_part_left = BaseLeg(self._elementsCount, nodeparams3, shoulder_left=True) shoulder_part_left._shoulder_left = True self.remove_duplicate_nodes_from_shoulder(shoulder_part_left, 1) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) - self.join_shoulder_to_bottom_part(shoulder_part_left, bottom_part, 1) + self.join_shoulder_to_bottom_part(shoulder_part_left, torso_upper_part, 1) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) neck_part = BaseLeg(self._elementsCount, nodeparams4) @@ -101,7 +126,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, neck_part) - joining_box_right = JoiningBoxRight([1, 4, 1], bottom_part, shoulder_part_left, joining_box) + joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) joining_box_3 = JoiningBox3([1, 4, 1], joining_box, neck_part) @@ -110,6 +135,362 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) + csh = shoulder_part.px[-1][shoulder_part._elementsCount[1]//2][shoulder_part._elementsCount[0]//2] + d1sh = shoulder_part.pd2[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] + d2sh = shoulder_part.pd1[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] + d3sh = shoulder_part.pd3[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] + d2sh = vector.setMagnitude(d2sh, -self.right_arm_radius) + d3sh = vector.setMagnitude(d3sh, self.right_arm_radius) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.right_arm_length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, self.right_arm_length/self.rightArmNumberOfElements) + d2w = vector.setMagnitude(d2sh, self.righ_wrist_radius) + d3w = vector.setMagnitude(d3sh, self.righ_wrist_radius) + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + ]) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.rightArmNumberOfElements) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(shoulder_part._elementsCount[1], shoulder_part._elementsCount[0], 0, 1, 1.0, + csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + right_arm_cylinder = CylinderMesh(fieldmodule, coordinates, self.rightArmNumberOfElements, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + right_arm_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.rightArmNumberOfElements + 1]) + + cylinder_shield = right_arm_cylinder._shield + for n2 in range(shoulder_part._elementsCount[1] + 1): + for n1 in range(shoulder_part._elementsCount[0] + 1): + cylinder_shield.nodeId[0][n2][n1] = shoulder_part.nodeId[-1][n2][n1] + cylinder_shield.px[0][n2][n1] = shoulder_part.px[-1][n2][n1] + cylinder_shield.pd1[0][n2][n1] = shoulder_part.pd1[-1][n2][n1] + cylinder_shield.pd2[0][n2][n1] = shoulder_part.pd2[-1][n2][n1] + cylinder_shield.pd3[0][n2][n1] = shoulder_part.pd3[-1][n2][n1] + + right_arm_cylinder.generateElements(mesh, fieldmodule, coordinates) + + + + csh = shoulder_part_left.px[-1][shoulder_part_left._elementsCount[1]//2][shoulder_part_left._elementsCount[0]//2] + d1sh = shoulder_part_left.pd2[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] + d2sh = shoulder_part_left.pd1[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] + d3sh = shoulder_part_left.pd3[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] + d2sh = vector.setMagnitude(d2sh, -self.right_arm_radius) + d3sh = vector.setMagnitude(d3sh, self.right_arm_radius) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.right_arm_length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, self.right_arm_length/self.rightArmNumberOfElements) + d2w = vector.setMagnitude(d2sh, self.righ_wrist_radius) + d3w = vector.setMagnitude(d3sh, self.righ_wrist_radius) + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + ]) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.rightArmNumberOfElements) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(shoulder_part_left._elementsCount[1], shoulder_part_left._elementsCount[0], 0, 1, 1.0, + csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + left_arm_cylinder = CylinderMesh(fieldmodule, coordinates, self.rightArmNumberOfElements, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + left_arm_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.rightArmNumberOfElements + 1]) + + cylinder_shield = left_arm_cylinder._shield + for n2 in range(shoulder_part_left._elementsCount[1] + 1): + for n1 in range(shoulder_part_left._elementsCount[0] + 1): + cylinder_shield.nodeId[0][n2][n1] = shoulder_part_left.nodeId[-1][n2][n1] + cylinder_shield.px[0][n2][n1] = shoulder_part_left.px[-1][n2][n1] + cylinder_shield.pd1[0][n2][n1] = shoulder_part_left.pd1[-1][n2][n1] + cylinder_shield.pd2[0][n2][n1] = shoulder_part_left.pd2[-1][n2][n1] + cylinder_shield.pd3[0][n2][n1] = shoulder_part_left.pd3[-1][n2][n1] + + left_arm_cylinder.generateElements(mesh, fieldmodule, coordinates) + + + + + + + csh = neck_part.px[-1][neck_part._elementsCount[1]//2][neck_part._elementsCount[0]//2] + d1sh = neck_part.pd2[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] + d2sh = neck_part.pd1[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] + d3sh = neck_part.pd3[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] + d2sh = vector.setMagnitude(d2sh, -self.neck_radius2) + d3sh = vector.setMagnitude(d3sh, self.neck_radius2) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.neck_length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, self.neck_length/self.neck_number_of_elements) + d2w = vector.setMagnitude(d2sh, self.neck_radius2) + d3w = vector.setMagnitude(d3sh, self.neck_radius2) + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + ]) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.neck_number_of_elements) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(neck_part._elementsCount[1], neck_part._elementsCount[0], 0, 1, 1.0, + csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + neck_cylinder = CylinderMesh(fieldmodule, coordinates, self.neck_number_of_elements, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + neck_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.neck_number_of_elements + 1]) + + cylinder_shield = neck_cylinder._shield + for n2 in range(neck_part._elementsCount[1] + 1): + for n1 in range(neck_part._elementsCount[0] + 1): + cylinder_shield.nodeId[0][n2][n1] = neck_part.nodeId[-1][n2][n1] + cylinder_shield.px[0][n2][n1] = neck_part.px[-1][n2][n1] + cylinder_shield.pd1[0][n2][n1] = neck_part.pd1[-1][n2][n1] + cylinder_shield.pd2[0][n2][n1] = neck_part.pd2[-1][n2][n1] + cylinder_shield.pd3[0][n2][n1] = neck_part.pd3[-1][n2][n1] + + neck_cylinder.generateElements(mesh, fieldmodule, coordinates) + + + neck_cyliner_shield = neck_cylinder._shield + csh = neck_cyliner_shield.px[-1][neck_cylinder._elementsCountAcrossMajor//2][neck_cylinder._elementsCountAcrossMinor//2] + d1sh = neck_cyliner_shield.pd2[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] + d2sh = neck_cyliner_shield.pd1[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] + d3sh = neck_cyliner_shield.pd3[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] + d2sh = vector.setMagnitude(d2sh, -self.neck_radius2) + d3sh = vector.setMagnitude(d3sh, self.neck_radius2) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.head_length/self.head_number_of_elements)], [1, 1]) + cw = vector.addVectors([cw, vector.setMagnitude([0.0, 1.0, 0.0], self.head_length/self.head_number_of_elements)], [1, 1]) + d1w = vector.setMagnitude(d1sh, self.head_length/self.head_number_of_elements) + d2w = vector.setMagnitude(d2sh, self.head_radius) + d3w = vector.setMagnitude(d3sh, self.neck_radius2) + path_list = [] + path_list.append([csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]) + path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + for ni in range(2, self.head_number_of_elements + 1): + cw = vector.addVectors([cw, vector.setMagnitude(d1w, self.head_length/self.head_number_of_elements)], [1, 1]) + if ni == 3: + path_list.append([cw, d1w, vector.scaleVector(d2w, 1.1), [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + else: + path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': 5 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], path_list) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.head_number_of_elements) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(neck_cylinder._elementsCountAcrossMajor,neck_cylinder._elementsCountAcrossMinor, 0, 1, 1.0, + csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + head_cylinder = CylinderMesh(fieldmodule, coordinates, self.head_number_of_elements, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + head_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.head_number_of_elements + 1]) + + cylinder_shield = head_cylinder._shield + for n2 in range(neck_cylinder._elementsCountAcrossMajor + 1): + for n1 in range(neck_cylinder._elementsCountAcrossMinor + 1): + cylinder_shield.nodeId[0][n2][n1] = neck_cyliner_shield.nodeId[-1][n2][n1] + cylinder_shield.px[0][n2][n1] = neck_cyliner_shield.px[-1][n2][n1] + cylinder_shield.pd1[0][n2][n1] = neck_cyliner_shield.pd1[-1][n2][n1] + cylinder_shield.pd2[0][n2][n1] = neck_cyliner_shield.pd2[-1][n2][n1] + cylinder_shield.pd3[0][n2][n1] = neck_cyliner_shield.pd3[-1][n2][n1] + + head_cylinder.generateElements(mesh, fieldmodule, coordinates) + + + sphere_shape = SphereShape.SPHERE_SHAPE_FULL + sphere_base = head_cylinder._ellipses[-1] + sphere_centre = sphere_base.centre + sphere_radius_3 = self.head_radius + axes = [sphere_base.majorAxis, sphere_base.minorAxis, + vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), sphere_radius_3)] + elementsCountAcross = [head_cylinder._elementsCountAcrossMajor, head_cylinder._elementsCountAcrossMinor, 4] + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] + sphereBoxDerivatives = [1, 3, 2] + + sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, + 0, 1, 1.0, + sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, + boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) + + hemisphere = ShieldMesh3D(elementsCountAcross, 0) + + + + # get hemisphere nodes from both cylinder end and top of the sphere and mix them + btx = hemisphere.px + btd1 = hemisphere.pd1 + btd2 = hemisphere.pd2 + btd3 = hemisphere.pd3 + + hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives + hemisphere._boxMapping = sphere1._shield3D._boxMapping + hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping + hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor + hemisphere._xi_mapping = sphere1._shield3D._xi_mapping + hemisphere._xi_signs = sphere1._shield3D._xi_signs + + for n3 in range(elementsCountAcross[2] + 1): + for n2 in range(elementsCountAcross[0] + 1): + for n1 in range(elementsCountAcross[1] + 1): + if n3 > elementsCountAcross[2]//2: + if sphere1._shield3D.px[n3][n2][n1]: + # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] + btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] + btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] + btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] + btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] + + # cylinder end + elif n3 == elementsCountAcross[2]//2: + # find nodes on the triple line. Note that cylinder and sphere have a little bit different + # numbering for nodes on the triple line + n2c, n1c = n2, n1 + if n2 < 1 and n1 == n2: + n1c = 1 + elif n2 < 1 and n1 == elementsCountAcross[1] - n2: + n1c = elementsCountAcross[1] - 1 + elif n2 > 3: + if n1 == elementsCountAcross[1] - n2: + n1c = 1 + elif n1 == n2: + n1c = elementsCountAcross[1] - 1 + hemisphere.nodeId[n3][n2][n1] = head_cylinder._shield.nodeId[-1][n2c][n1c] + + # generate hemisphere extra nodes. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, + rangeOfRequiredElements) + + # generate himsphere elements. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, + rangeOfRequiredElements) + + + + csh = torso_upper_part.px[0][torso_upper_part._elementsCount[1]//2][torso_upper_part._elementsCount[0]//2] + d1sh = torso_upper_part.pd2[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] + d2sh = torso_upper_part.pd1[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] + d3sh = torso_upper_part.pd3[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] + d2sh = vector.setMagnitude(d2sh, -self.torso_radius) + d3sh = vector.setMagnitude(d3sh, self.torso_radius) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, -self.lower_torso_length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, self.lower_torso_length/self.lower_torso_number_of_elements) + d2w = vector.setMagnitude(d2sh, self.lower_torso_radii[0]) + d3w = vector.setMagnitude(d3sh, self.lower_torso_radii[1]) + + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + ]) + }) + + cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.lower_torso_number_of_elements) + + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + + base = CylinderEnds(torso_upper_part._elementsCount[1], torso_upper_part._elementsCount[0], 0, 1, 1.0, + csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + lower_torso_cylinder = CylinderMesh(fieldmodule, coordinates, self.lower_torso_number_of_elements, base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + lower_torso_cylinder.generateNodes(nodes, fieldmodule, coordinates, [0, self.lower_torso_number_of_elements]) + + cylinder_shield = lower_torso_cylinder._shield + for n2 in range(torso_upper_part._elementsCount[1] + 1): + for n1 in range(torso_upper_part._elementsCount[0] + 1): + cylinder_shield.nodeId[-1][n2][n1] = torso_upper_part.nodeId[0][n2][n1] + cylinder_shield.px[-1][n2][n1] = torso_upper_part.px[0][n2][n1] + cylinder_shield.pd1[-1][n2][n1] = torso_upper_part.pd1[0][n2][n1] + cylinder_shield.pd2[-1][n2][n1] = torso_upper_part.pd2[0][n2][n1] + cylinder_shield.pd3[-1][n2][n1] = torso_upper_part.pd3[0][n2][n1] + + lower_torso_cylinder.generateElements(mesh, fieldmodule, coordinates) + + + smoothing = DerivativeSmoothing(self._region, coordinates) + smoothing.smooth(True) + del smoothing + # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) @@ -176,7 +557,7 @@ def _get_node_params(self): :return: """ - armpit = [1.2, 0.0, 1.0] + armpit = self.armpit x_bottom_base_centre = [0.0, 0.0, 0.0] x_bottom_base_curve1 = [self.torso_radius, 0.0, 0.0] x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] @@ -203,9 +584,14 @@ def _get_node_params(self): d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] kv = [0.0, 1.0, 0.0] - cv = [self.right_arm_length, 0.0, 0.0] + cv = [self.right_shoulder_length, 0.0, 0.0] cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) +<<<<<<< HEAD ce = vector.addVectors([cev, [0.0, 0.0, self.shoulder_height]], [1, 1]) +======= + cevunit = vector.normalise(cev) + ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) x_shoulder_end_centre = ce # x_shoulder_end_curve1 = [1.7, 0.0, self.shoulder_height - self.left_arm_radius] x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) @@ -214,6 +600,10 @@ def _get_node_params(self): # d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1]), vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1])] +<<<<<<< HEAD +======= + +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] nodeparams2 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, @@ -226,11 +616,20 @@ def _get_node_params(self): x_shoulder_base_curve1 = [-0.75, 1.0, self.shoulder_height] d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] - x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] - x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] - x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] - d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] - d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] + kv = [0.0, 1.0, 0.0] + cv = [-self.right_shoulder_length, 0.0, 0.0] + cev = vector.rotateVectorAroundVector(cv, kv, -self.left_arm_angle) + ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) + x_shoulder_end_centre = ce + # x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius)], [1, 1]) + # x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.left_arm_radius] + x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) + # x_shoulder_end_curve1 = [-1.7, self.left_arm_radius, self.shoulder_height] + d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1]), + vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1])] + # d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] + d1_shoulder_end_curve1 = [[-0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, d1_shoulder_base_curve2], @@ -1132,7 +1531,11 @@ class BaseLeg: """ Base case for creating a child """ +<<<<<<< HEAD def __init__(self, elementsCount, nodeparams): +======= + def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_left=False): +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) """ :param fieldmodule: @@ -1157,9 +1560,15 @@ def __init__(self, elementsCount, nodeparams): n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) plane = [n[0], n[1], n[2], d] - mirror = Mirror(plane) + mirrore = Mirror(plane) + if shoulder_left: + mirror0 = Mirror([0.0, 0.0, 1.0, nodeparams[0][0][2]]) for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): for n3 in range(elementsCount[2]+1): + if shoulder_left and n3 == 0: + mirror = mirror0 + else: + mirror = mirrore for n1 in range(elementsCount[0]//2+1): n3q = n3 n2q = elementsCount[1] - n2 @@ -1172,9 +1581,21 @@ def __init__(self, elementsCount, nodeparams): n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) plane = [n[0], n[1], n[2], d] +<<<<<<< HEAD mirror = Mirror(plane) for n2 in range(elementsCount[1]+1): for n3 in range(elementsCount[2]+1): +======= + mirrore = Mirror(plane) + if shoulder_right: + mirror0 = Mirror([0.0, 0.0, 1.0, nodeparams[0][0][2]]) + for n2 in range(elementsCount[1]+1): + for n3 in range(elementsCount[2]+1): + if shoulder_right and n3 == 0: + mirror = mirror0 + else: + mirror = mirrore +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): n3q = n3 n2q = n2 diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index f2ac6fff..100be098 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -136,7 +136,11 @@ class CylinderMesh: def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end=None, cylinderShape=CylinderShape.CYLINDER_SHAPE_FULL, +<<<<<<< HEAD tapered=None, cylinderCentralPath=None, useCrossDerivatives=False , meshGroupsElementsAlong=[], meshGroups=[]): +======= + tapered=None, cylinderCentralPath=None, useCrossDerivatives=False, rangeOfRequiredElementsAlong=None): +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -173,6 +177,7 @@ def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end= self._endElementIdentifier = 1 self._cylinderShape = cylinderShape self._cylinderType = CylinderType.CYLINDER_STRAIGHT + self._rangeOfRequiredElementsAlong = rangeOfRequiredElementsAlong if (tapered is not None) or cylinderCentralPath: self._cylinderType = CylinderType.CYLINDER_TAPERED self._tapered = tapered @@ -256,8 +261,8 @@ def createCylinderMesh3d(self, fieldModule, coordinates): self._shield.pd2[n3][n2][n1] = self._shield.pd2[0][n2][n1] self._shield.pd3[n3][n2][n1] = self._shield.pd3[0][n2][n1] - self.generateNodes(nodes, fieldModule, coordinates) - self.generateElements(mesh, fieldModule, coordinates) + self.generateNodes(nodes, fieldModule, coordinates, self._rangeOfRequiredElementsAlong) + self.generateElements(mesh, fieldModule, coordinates, self._rangeOfRequiredElementsAlong) if self._end is None: self._end = CylinderEnds(self._elementsCountAcrossMajor, self._elementsCountAcrossMinor, @@ -371,7 +376,7 @@ def copyEllipsesNodesToShieldNodes(self, n3): self._shield.pd2[n3] = self._ellipses[n3].pd2 self._shield.pd3[n3] = self._ellipses[n3].pd3 - def generateNodes(self, nodes, fieldModule, coordinates): + def generateNodes(self, nodes, fieldModule, coordinates, rangeOfRequiredElementsAlong=None): """ Create cylinder nodes from coordinates. :param nodes: nodes from coordinates. @@ -380,10 +385,11 @@ 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, + rangeOfRequiredElementsAlong=rangeOfRequiredElementsAlong) self._endNodeIdentifier = nodeIdentifier - def generateElements(self, mesh, fieldModule, coordinates): + def generateElements(self, mesh, fieldModule, coordinates, rangeOfRequiredElementsAlong=None): """ Create cylinder elements from nodes. :param mesh: @@ -392,8 +398,13 @@ def generateElements(self, mesh, fieldModule, coordinates): """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier +<<<<<<< HEAD elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, self._meshGroupsElementsAlong, self._meshGroups) +======= + elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, [], + rangeOfRequiredElementsAlong=rangeOfRequiredElementsAlong) +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) self._endElementIdentifier = elementIdentifier def getElementsCountAround(self): diff --git a/src/scaffoldmaker/utils/shieldmesh.py b/src/scaffoldmaker/utils/shieldmesh.py index 868f806a..f5e06bc7 100644 --- a/src/scaffoldmaker/utils/shieldmesh.py +++ b/src/scaffoldmaker/utils/shieldmesh.py @@ -434,7 +434,8 @@ 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, mirrorPlane=None, + rangeOfRequiredElementsAlong=None): """ Create shield nodes from coordinates. :param fieldmodule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. @@ -462,8 +463,13 @@ def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPla if self._mode == ShieldShape2D.SHIELD_SHAPE_FULL and mirrorPlane: self.generateNodesForOtherHalf(mirrorPlane) + if rangeOfRequiredElementsAlong is None: + rangeOfRequiredElementsAlong = [0, self.elementsCountAlong] + for n2 in range(self.elementsCountUpFull + 1): for n3 in range(self.elementsCountAlong+1): + if n3 < rangeOfRequiredElementsAlong[0] or n3 > rangeOfRequiredElementsAlong[1]: + continue for n1 in range(self.elementsCountAcross + 1): if self.px[n3][n2][n1]: node = nodes.createNode(nodeIdentifier, nodetemplate) @@ -477,7 +483,12 @@ def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPla return nodeIdentifier +<<<<<<< HEAD def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroupsElementsAlong=[], meshGroups=[]): +======= + def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroups=[], + rangeOfRequiredElementsAlong=None): +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) """ Create shield elements from nodes. :param fieldmodule: Zinc fieldmodule to create elements in. @@ -502,11 +513,16 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes elementtemplate1 = mesh.createElementtemplate() elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) +<<<<<<< HEAD elementEnd = [] count = 0 for c in meshGroupsElementsAlong: count += c elementEnd.append(count) +======= + if rangeOfRequiredElementsAlong is None: + rangeOfRequiredElementsAlong = [0, self.elementsCountAlong] +>>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) isEven = (self.elementsCountAcross % 2) == 0 e1a = self.elementsCountRim @@ -520,6 +536,8 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes e2y = e2z - 1 e2x = e2z - 2 for e3 in range(self.elementsCountAlong): + if e3 < rangeOfRequiredElementsAlong[0] or e3 > rangeOfRequiredElementsAlong[1]: + continue for e2 in range(self.elementsCountUpFull): for e1 in range(self.elementsCountAcross): eft1 = eft From 74328fd3630d7c35e04a2e6d0ae851e1b089054e Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 1 Apr 2022 14:38:04 +1300 Subject: [PATCH 15/38] modify the meshtype_1d_bifurcationtree1.py to extract the stickman data. --- .../meshtypes/meshtype_1d_bifurcationtree1.py | 40 +++++++++++++++++++ .../meshtype_3d_solidbifurcation2.py | 24 +++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py b/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py index 4fdf6228..7aff802c 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py @@ -303,3 +303,43 @@ def _generateZincModelTree(self, treeNode, parentNode, nextNodeIdentifier, nextE nextNodeIdentifier, nextElementIdentifier = self._generateZincModelTree(childTreeNode, node, nextNodeIdentifier, nextElementIdentifier) return nextNodeIdentifier, nextElementIdentifier + + +def extractPathParametersFromRegion(region, valueLabels, groupName=None): + ''' + Returns parameters of all nodes in region in identifier order. + Assumes nodes in region have field coordinates (1 to 3 components). + Currently limited to nodes with exactly value, d_ds1, d_ds2, d2_ds12, + same as path 1 scaffold. + :param valueLabels: List of parameters required as list of node value labels. e.g. [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1]. + :param groupName: Optional name of Zinc group to get parameters from. + :return: cx, cd1, cd2, cd12 (all padded with zeroes to 3 components) + ''' + fieldmodule = region.getFieldmodule() + coordinates = fieldmodule.findFieldByName('coordinates').castFiniteElement() + componentsCount = coordinates.getNumberOfComponents() + assert componentsCount in [ 1, 2, 3 ], 'extractPathParametersFromRegion. Invalid coordinates number of components' + cache = fieldmodule.createFieldcache() + + valueLabelsCount = len(valueLabels) + returnValues = [[] for i in range(valueLabelsCount)] + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + if groupName: + group = fieldmodule.findFieldByName(groupName).castGroup() + nodeGroup = group.getFieldNodeGroup(nodes) + if nodeGroup.isValid(): + nodes = nodeGroup.getNodesetGroup() + else: + print('extractPathParametersFromRegion: missing group "' + groupName + '"') + nodeIter = nodes.createNodeiterator() + node = nodeIter.next() + while node.isValid(): + cache.setNode(node) + for i in range(valueLabelsCount): + result, values = coordinates.getNodeParameters(cache, -1, valueLabels[i], 1, componentsCount) + for c in range(componentsCount, 3): + values.append(0.0) + returnValues[i].append(values) + node = nodeIter.next() + + return returnValues diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 9c5b31f8..9734cf0c 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -16,6 +16,8 @@ from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import MeshType_1d_bifurcationtree1 from opencmiss.zinc.node import Node from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh +from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import extractPathParametersFromRegion +from scaffoldmaker.utils import vector class MeshType_3d_solidbifurcation2(Scaffold_base): @@ -273,6 +275,28 @@ def generateBaseMesh(region, options): lower_torso_length = options['Lower torso length'] lower_torso_number_of_elements = options['Lower torso number of elements'] lower_torso_radii = options['Lower torso radii'] + + + + tmpRegion = region.createRegion() + centralPath.generate(tmpRegion) + cx, cd1, cd2, cd3, cd12, cd13 = extractPathParametersFromRegion(tmpRegion, + [Node.VALUE_LABEL_VALUE, + Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, + Node.VALUE_LABEL_D_DS3, + Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D2_DS1DS3]) + + deltacx = vector.vectorRejection(vector.addVectors([cx[2], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + right_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) + if cx[2][2] > cx[1][2]: + right_arm_angle = -right_arm_angle + + deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + left_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) + if cx[3][2] > cx[1][2]: + left_arm_angle = -left_arm_angle + # bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, # neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length, # shoulder_joint, armpit, neck_shoulder, shoulder_point, shoulder_start) From 5f7f91db9a2b5dd0f175c1dd0ab4aad52a9abbb4 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 12 Apr 2022 10:32:17 +1200 Subject: [PATCH 16/38] Add stickman --- .../meshtypes/meshtype_1d_bifurcationtree1.py | 40 ----- .../meshtypes/meshtype_1d_stickman1.py | 170 ++++++++++++++++++ .../meshtype_3d_solidbifurcation2.py | 45 +++-- src/scaffoldmaker/scaffolds.py | 2 + 4 files changed, 192 insertions(+), 65 deletions(-) create mode 100644 src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py b/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py index 7aff802c..4fdf6228 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_1d_bifurcationtree1.py @@ -303,43 +303,3 @@ def _generateZincModelTree(self, treeNode, parentNode, nextNodeIdentifier, nextE nextNodeIdentifier, nextElementIdentifier = self._generateZincModelTree(childTreeNode, node, nextNodeIdentifier, nextElementIdentifier) return nextNodeIdentifier, nextElementIdentifier - - -def extractPathParametersFromRegion(region, valueLabels, groupName=None): - ''' - Returns parameters of all nodes in region in identifier order. - Assumes nodes in region have field coordinates (1 to 3 components). - Currently limited to nodes with exactly value, d_ds1, d_ds2, d2_ds12, - same as path 1 scaffold. - :param valueLabels: List of parameters required as list of node value labels. e.g. [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1]. - :param groupName: Optional name of Zinc group to get parameters from. - :return: cx, cd1, cd2, cd12 (all padded with zeroes to 3 components) - ''' - fieldmodule = region.getFieldmodule() - coordinates = fieldmodule.findFieldByName('coordinates').castFiniteElement() - componentsCount = coordinates.getNumberOfComponents() - assert componentsCount in [ 1, 2, 3 ], 'extractPathParametersFromRegion. Invalid coordinates number of components' - cache = fieldmodule.createFieldcache() - - valueLabelsCount = len(valueLabels) - returnValues = [[] for i in range(valueLabelsCount)] - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - if groupName: - group = fieldmodule.findFieldByName(groupName).castGroup() - nodeGroup = group.getFieldNodeGroup(nodes) - if nodeGroup.isValid(): - nodes = nodeGroup.getNodesetGroup() - else: - print('extractPathParametersFromRegion: missing group "' + groupName + '"') - nodeIter = nodes.createNodeiterator() - node = nodeIter.next() - while node.isValid(): - cache.setNode(node) - for i in range(valueLabelsCount): - result, values = coordinates.getNodeParameters(cache, -1, valueLabels[i], 1, componentsCount) - for c in range(componentsCount, 3): - values.append(0.0) - returnValues[i].append(values) - node = nodeIter.next() - - return returnValues diff --git a/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py new file mode 100644 index 00000000..23b34b64 --- /dev/null +++ b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py @@ -0,0 +1,170 @@ +""" +Generates a 1-D stickman that is used for body posture. +""" + +from __future__ import division + +from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates, findOrCreateFieldGroup +from opencmiss.utils.zinc.general import ChangeManager +from opencmiss.zinc.element import Element, Elementbasis +from opencmiss.zinc.field import Field +from opencmiss.zinc.node import Node +from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base +from scaffoldmaker.utils import vector +from scaffoldmaker.utils.interpolation import smoothCubicHermiteCrossDerivativesLine + + +class MeshType_1d_stickman1(Scaffold_base): + ''' + classdocs + ''' + @staticmethod + def getName(): + return '1D Stickman 1' + + @staticmethod + def getDefaultOptions(parameterSetName='Default'): + return { + 'Coordinate dimensions' : 3, + } + + @staticmethod + def getOrderedOptionNames(): + return [ + 'Coordinate dimensions' + ] + + @staticmethod + def checkOptions(options): + dependentChanges = False + + return dependentChanges + + @classmethod + def generateBaseMesh(cls, region, options): + """ + :param region: Zinc region to define model in. Must be empty. + :param options: Dict containing options. See getDefaultOptions(). + :return: [] empty list of AnnotationGroup + """ + + fieldmodule = region.getFieldmodule() + coordinates = findOrCreateFieldCoordinates(fieldmodule, components_count=3) + cache = fieldmodule.createFieldcache() + + ################# + # Create nodes + ################# + + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + + nodeIdentifier = 1 + x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], + [-0.25, 0.0, 0.81], [-0.5, 0.0, 0.87], [-0.25, 0.0, 0.25], [-0.5, 0.0, 0.0], + [0.25, 0.0, 0.81], [0.5, 0.0, 0.87], [0.25, 0.0, 0.25], [0.5, 0.0, 0.0]] + + for x in x_list: + node = nodes.createNode(nodeIdentifier, nodetemplate) + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, x) + nodeIdentifier += 1 + + ################# + # Create elements + ################# + + mesh = fieldmodule.findMeshByDimension(1) + linearLagrangeBasis = fieldmodule.createElementbasis(1, Elementbasis.FUNCTION_TYPE_LINEAR_LAGRANGE) + eft = mesh.createElementfieldtemplate(linearLagrangeBasis) + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_LINE) + result = elementtemplate.defineField(coordinates, -1, eft) + + elementIdentifier = 1 + lines = [[1, 2], [2, 3], + [2, 4], [4, 5], [3, 6], [6, 7], + [2, 8], [8, 9], [3, 10], [10, 11]] + for e in lines: + element = mesh.createElement(elementIdentifier, elementtemplate) + element.setNodesByIdentifier(eft, e) + elementIdentifier += 1 + + return [] + + +def extractPathParametersFromRegion(region, valueLabels, groupName=None): + ''' + Returns parameters of all nodes in region in identifier order. + Assumes nodes in region have field coordinates (1 to 3 components). + :param valueLabels: List of parameters required as list of node value labels. e.g. [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1]. + :param groupName: Optional name of Zinc group to get parameters from. + :return: cx, cd1, cd2, cd12 (all padded with zeroes to 3 components) + ''' + fieldmodule = region.getFieldmodule() + coordinates = fieldmodule.findFieldByName('coordinates').castFiniteElement() + componentsCount = coordinates.getNumberOfComponents() + assert componentsCount in [ 1, 2, 3 ], 'extractPathParametersFromRegion. Invalid coordinates number of components' + cache = fieldmodule.createFieldcache() + + valueLabelsCount = len(valueLabels) + returnValues = [[] for i in range(valueLabelsCount)] + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + if groupName: + group = fieldmodule.findFieldByName(groupName).castGroup() + nodeGroup = group.getFieldNodeGroup(nodes) + if nodeGroup.isValid(): + nodes = nodeGroup.getNodesetGroup() + else: + print('extractPathParametersFromRegion: missing group "' + groupName + '"') + nodeIter = nodes.createNodeiterator() + node = nodeIter.next() + while node.isValid(): + cache.setNode(node) + for i in range(valueLabelsCount): + result, values = coordinates.getNodeParameters(cache, -1, valueLabels[i], 1, componentsCount) + for c in range(componentsCount, 3): + values.append(0.0) + returnValues[i].append(values) + node = nodeIter.next() + + return returnValues + + +def setPathParameters(region, nodeValueLabels, nodeValues, editGroupName=None): + ''' + Set node parameters for coordinates field in path from listed values. + :param nodeValueLabels: List of nodeValueLabels to set e.g. [ Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1 ] + :param nodeValues: List of values for each type e.g. [ xlist, d1list ] + :param editGroupName: Optional name of existing or new Zinc group to record modified nodes in. + ''' + fieldmodule = region.getFieldmodule() + coordinates = fieldmodule.findFieldByName('coordinates').castFiniteElement() + componentsCount = coordinates.getNumberOfComponents() + # following requires at least one value label and node, assumes consistent values and components counts + nodeValueLabelsCount = len(nodeValueLabels) + nodesCount = len(nodeValues[0]) + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + assert nodesCount == nodes.getSize() + with ChangeManager(fieldmodule): + if editGroupName: + editGroup = findOrCreateFieldGroup(fieldmodule, editGroupName, managed=True) + editNodeGroup = editGroup.getFieldNodeGroup(nodes) + if not editNodeGroup.isValid(): + editNodeGroup = editGroup.createFieldNodeGroup(nodes) + editNodesetGroup = editNodeGroup.getNodesetGroup() + cache = fieldmodule.createFieldcache() + nodeIter = nodes.createNodeiterator() + node = nodeIter.next() + n = 0 + while node.isValid(): + cache.setNode(node) + for v in range(nodeValueLabelsCount): + coordinates.setNodeParameters(cache, -1, nodeValueLabels[v], 1, nodeValues[v][n]) + if editGroupName: + editNodesetGroup.addNode(node) + node = nodeIter.next() + n += 1 diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 9734cf0c..fadcf34f 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -6,17 +6,16 @@ from __future__ import division import math import copy + from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base from scaffoldmaker.utils.meshrefinement import MeshRefinement -from scaffoldmaker.utils.cylindermesh import CylinderMesh, CylinderShape, CylinderEnds, CylinderCentralPath -from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 -from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import MeshType_1d_bifurcationtree1 +from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import MeshType_1d_stickman1 from opencmiss.zinc.node import Node from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh -from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import extractPathParametersFromRegion +from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import extractPathParametersFromRegion from scaffoldmaker.utils import vector @@ -43,16 +42,14 @@ class MeshType_3d_solidbifurcation2(Scaffold_base): # # [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] # # ]) # }), - 'control curves': ScaffoldPackage(MeshType_1d_bifurcationtree1, { + 'control curves': ScaffoldPackage(MeshType_1d_stickman1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + } + }), + 'control curves1': ScaffoldPackage(MeshType_1d_stickman1, { 'scaffoldSettings': { - 'Number of generations' : 2, - 'Root diameter' : 0.25, - 'Root length' : 1.0, - 'Fork angle degrees' : 10.0, - 'Fork diameter ratio' : 0.9, - 'Branch arc angle degrees' : 40.0, - 'Branch diameter ratio' : 0.8, - 'Branch length ratio' : 0.8 + 'Coordinate dimensions': 3, } }) } @@ -64,8 +61,10 @@ def getName(): @classmethod def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] + centralPathOption1 = cls.centralPathDefaultScaffoldPackages['control curves1'] options = { 'Central path': copy.deepcopy(centralPathOption), + 'Central path1': copy.deepcopy(centralPathOption1), 'Armpit': [1.2, 0.0, 1.0], 'Torso radius': 1.0, 'Left arm radius': 1.0, @@ -114,6 +113,7 @@ def getDefaultOptions(cls, parameterSetName='Default'): def getOrderedOptionNames(): return [ 'Central path', + 'Central path1', 'Armpit', 'Torso radius', 'Left arm radius', @@ -280,21 +280,16 @@ def generateBaseMesh(region, options): tmpRegion = region.createRegion() centralPath.generate(tmpRegion) - cx, cd1, cd2, cd3, cd12, cd13 = extractPathParametersFromRegion(tmpRegion, - [Node.VALUE_LABEL_VALUE, - Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, - Node.VALUE_LABEL_D_DS3, - Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D2_DS1DS3]) + cx = extractPathParametersFromRegion(tmpRegion, [Node.VALUE_LABEL_VALUE])[0] - deltacx = vector.vectorRejection(vector.addVectors([cx[2], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - right_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) - if cx[2][2] > cx[1][2]: + deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + right_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) + if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: right_arm_angle = -right_arm_angle - deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - left_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) - if cx[3][2] > cx[1][2]: + deltacx = vector.vectorRejection(vector.addVectors([cx[7], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + left_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) + if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: left_arm_angle = -left_arm_angle # bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, diff --git a/src/scaffoldmaker/scaffolds.py b/src/scaffoldmaker/scaffolds.py index a6d83be3..8359eed8 100644 --- a/src/scaffoldmaker/scaffolds.py +++ b/src/scaffoldmaker/scaffolds.py @@ -6,6 +6,7 @@ from scaffoldmaker.meshtypes.meshtype_1d_bifurcationtree1 import MeshType_1d_bifurcationtree1 from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import MeshType_1d_stickman1 from scaffoldmaker.meshtypes.meshtype_2d_plate1 import MeshType_2d_plate1 from scaffoldmaker.meshtypes.meshtype_2d_platehole1 import MeshType_2d_platehole1 from scaffoldmaker.meshtypes.meshtype_2d_sphere1 import MeshType_2d_sphere1 @@ -68,6 +69,7 @@ def __init__(self): self._allScaffoldTypes = [ MeshType_1d_bifurcationtree1, MeshType_1d_path1, + MeshType_1d_stickman1, MeshType_2d_plate1, MeshType_2d_platehole1, MeshType_2d_sphere1, From bd91bea34ccc48b83ddf297800e333f819dfa339 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 21 Apr 2022 22:22:27 +1200 Subject: [PATCH 17/38] Modify axes and clean the code and make some classes --- src/scaffoldmaker/utils/bifurcation3d2.py | 829 +++++++++------------- 1 file changed, 342 insertions(+), 487 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 9bf7d0f7..ea1301c3 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -25,7 +25,6 @@ from scaffoldmaker.utils.shieldmesh import ShieldMesh3D - class BifurcationMesh: """ Bifurction mesh generator. @@ -89,17 +88,21 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) mesh = fieldmodule.findMeshByDimension(3) - nodeparams1, nodeparams2, nodeparams3, nodeparams4 = self._get_node_params() + base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() - torso_upper_part = BaseLeg(self._elementsCount, nodeparams1) + torso_upper_part = BaseLeg(self._elementsCount, base_c) self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) +<<<<<<< HEAD <<<<<<< HEAD shoulder_part = BaseLeg(self._elementsCount, nodeparams2) ======= shoulder_part = BaseLeg(self._elementsCount, nodeparams2, shoulder_right=True) >>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) +======= + shoulder_part = BaseLeg(self._elementsCount, shoulder_lc, shoulder_right=True) +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) shoulder_part._shoulder = True self.remove_duplicate_nodes_from_shoulder(shoulder_part) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) @@ -111,21 +114,20 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.join_box_to_bottom_and_shoulder(joining_box, torso_upper_part, shoulder_part) self.generateElements(mesh, fieldmodule, coordinates, joining_box) - shoulder_part_left = BaseLeg(self._elementsCount, nodeparams3, shoulder_left=True) + shoulder_part_left = BaseLeg(self._elementsCount, shoulder_rc, shoulder_left=True) shoulder_part_left._shoulder_left = True self.remove_duplicate_nodes_from_shoulder(shoulder_part_left, 1) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) self.join_shoulder_to_bottom_part(shoulder_part_left, torso_upper_part, 1) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) - neck_part = BaseLeg(self._elementsCount, nodeparams4) + neck_part = BaseLeg(self._elementsCount, neck_c) neck_part._neck = True self.remove_duplicate_nodes_from_neck(neck_part) self.generateNodes(nodes, fieldmodule, coordinates, neck_part) self.join_neck_to_torso(neck_part, shoulder_part, shoulder_part_left) self.generateElements(mesh, fieldmodule, coordinates, neck_part) - joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) @@ -135,185 +137,187 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) - csh = shoulder_part.px[-1][shoulder_part._elementsCount[1]//2][shoulder_part._elementsCount[0]//2] - d1sh = shoulder_part.pd2[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] - d2sh = shoulder_part.pd1[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] - d3sh = shoulder_part.pd3[-1][shoulder_part._elementsCount[1] // 2][shoulder_part._elementsCount[0] // 2] - d2sh = vector.setMagnitude(d2sh, -self.right_arm_radius) - d3sh = vector.setMagnitude(d3sh, self.right_arm_radius) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.right_arm_length)], [1, 1]) - d1w = vector.setMagnitude(d1sh, self.right_arm_length/self.rightArmNumberOfElements) - d2w = vector.setMagnitude(d2sh, self.righ_wrist_radius) - d3w = vector.setMagnitude(d3sh, self.righ_wrist_radius) - - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], - [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], - ]) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.rightArmNumberOfElements) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(shoulder_part._elementsCount[1], shoulder_part._elementsCount[0], 0, 1, 1.0, - csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - right_arm_cylinder = CylinderMesh(fieldmodule, coordinates, self.rightArmNumberOfElements, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - right_arm_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.rightArmNumberOfElements + 1]) - - cylinder_shield = right_arm_cylinder._shield - for n2 in range(shoulder_part._elementsCount[1] + 1): - for n1 in range(shoulder_part._elementsCount[0] + 1): - cylinder_shield.nodeId[0][n2][n1] = shoulder_part.nodeId[-1][n2][n1] - cylinder_shield.px[0][n2][n1] = shoulder_part.px[-1][n2][n1] - cylinder_shield.pd1[0][n2][n1] = shoulder_part.pd1[-1][n2][n1] - cylinder_shield.pd2[0][n2][n1] = shoulder_part.pd2[-1][n2][n1] - cylinder_shield.pd3[0][n2][n1] = shoulder_part.pd3[-1][n2][n1] - - right_arm_cylinder.generateElements(mesh, fieldmodule, coordinates) - - - - csh = shoulder_part_left.px[-1][shoulder_part_left._elementsCount[1]//2][shoulder_part_left._elementsCount[0]//2] - d1sh = shoulder_part_left.pd2[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] - d2sh = shoulder_part_left.pd1[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] - d3sh = shoulder_part_left.pd3[-1][shoulder_part_left._elementsCount[1] // 2][shoulder_part_left._elementsCount[0] // 2] - d2sh = vector.setMagnitude(d2sh, -self.right_arm_radius) - d3sh = vector.setMagnitude(d3sh, self.right_arm_radius) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.right_arm_length)], [1, 1]) - d1w = vector.setMagnitude(d1sh, self.right_arm_length/self.rightArmNumberOfElements) - d2w = vector.setMagnitude(d2sh, self.righ_wrist_radius) - d3w = vector.setMagnitude(d3sh, self.righ_wrist_radius) - - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], - [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], - ]) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.rightArmNumberOfElements) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(shoulder_part_left._elementsCount[1], shoulder_part_left._elementsCount[0], 0, 1, 1.0, - csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - left_arm_cylinder = CylinderMesh(fieldmodule, coordinates, self.rightArmNumberOfElements, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - left_arm_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.rightArmNumberOfElements + 1]) - - cylinder_shield = left_arm_cylinder._shield - for n2 in range(shoulder_part_left._elementsCount[1] + 1): - for n1 in range(shoulder_part_left._elementsCount[0] + 1): - cylinder_shield.nodeId[0][n2][n1] = shoulder_part_left.nodeId[-1][n2][n1] - cylinder_shield.px[0][n2][n1] = shoulder_part_left.px[-1][n2][n1] - cylinder_shield.pd1[0][n2][n1] = shoulder_part_left.pd1[-1][n2][n1] - cylinder_shield.pd2[0][n2][n1] = shoulder_part_left.pd2[-1][n2][n1] - cylinder_shield.pd3[0][n2][n1] = shoulder_part_left.pd3[-1][n2][n1] - - left_arm_cylinder.generateElements(mesh, fieldmodule, coordinates) - - - - - - - csh = neck_part.px[-1][neck_part._elementsCount[1]//2][neck_part._elementsCount[0]//2] - d1sh = neck_part.pd2[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] - d2sh = neck_part.pd1[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] - d3sh = neck_part.pd3[-1][neck_part._elementsCount[1] // 2][neck_part._elementsCount[0] // 2] - d2sh = vector.setMagnitude(d2sh, -self.neck_radius2) - d3sh = vector.setMagnitude(d3sh, self.neck_radius2) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.neck_length)], [1, 1]) - d1w = vector.setMagnitude(d1sh, self.neck_length/self.neck_number_of_elements) - d2w = vector.setMagnitude(d2sh, self.neck_radius2) - d3w = vector.setMagnitude(d3sh, self.neck_radius2) - - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], - [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], - ]) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.neck_number_of_elements) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(neck_part._elementsCount[1], neck_part._elementsCount[0], 0, 1, 1.0, - csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - neck_cylinder = CylinderMesh(fieldmodule, coordinates, self.neck_number_of_elements, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - neck_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.neck_number_of_elements + 1]) - - cylinder_shield = neck_cylinder._shield - for n2 in range(neck_part._elementsCount[1] + 1): - for n1 in range(neck_part._elementsCount[0] + 1): - cylinder_shield.nodeId[0][n2][n1] = neck_part.nodeId[-1][n2][n1] - cylinder_shield.px[0][n2][n1] = neck_part.px[-1][n2][n1] - cylinder_shield.pd1[0][n2][n1] = neck_part.pd1[-1][n2][n1] - cylinder_shield.pd2[0][n2][n1] = neck_part.pd2[-1][n2][n1] - cylinder_shield.pd3[0][n2][n1] = neck_part.pd3[-1][n2][n1] - - neck_cylinder.generateElements(mesh, fieldmodule, coordinates) - + class BranchCylinder: + def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, attach_bottom=True): + if attach_bottom: + n3, n3p = 0, -1 + node_ranges = [1, elements_count[2] + 1] + else: + n3, n3p = -1, 0 + node_ranges = [0, elements_count[2]] + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': len(path_list) - 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, + Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], + path_list) + }) + cylinderCentralPath = CylinderCentralPath(region, centralPath, elements_count[2]) + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + centre = path_list[0][0] + base = CylinderEnds(elements_count[1], elements_count[0], 0, 1, 1.0, + centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + cylinder = CylinderMesh(fieldmodule, coordinates, elements_count[2], base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + cylinder.generateNodes(nodes, fieldmodule, coordinates, node_ranges) + + cylinder_shield = cylinder._shield + for n2 in range(elements_count[1] + 1): + for n1 in range(elements_count[0] + 1): + cylinder_shield.nodeId[n3][n2][n1] = part1.nodeId[n3p][n2][n1] + cylinder_shield.px[n3][n2][n1] = part1.px[n3p][n2][n1] + cylinder_shield.pd1[n3][n2][n1] = part1.pd1[n3p][n2][n1] + cylinder_shield.pd2[n3][n2][n1] = part1.pd2[n3p][n2][n1] + cylinder_shield.pd3[n3][n2][n1] = part1.pd3[n3p][n2][n1] + + cylinder.generateElements(mesh, fieldmodule, coordinates) + self.cylinder = cylinder + + def get_cylinder(self): + return self.cylinder + + class PathNodes: + def __init__(self, part1, radius, length, elements_count, attach_bottom=True): + if attach_bottom: + n3 = -1 + sc = 1 + else: + n3 = 0 + sc = -1 + csh = part1.px[n3][elements_count[1] // 2][elements_count[0] // 2] + d1sh = part1.pd2[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = part1.pd1[n3][elements_count[1] // 2][elements_count[0] // 2] + d3sh = part1.pd3[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = vector.setMagnitude(d2sh, -radius[0][0]) + d3sh = vector.setMagnitude(d3sh, radius[0][1]) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, sc*length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, length / elements_count[2]) + d2w = vector.setMagnitude(d2sh, radius[1][0]) + d3w = vector.setMagnitude(d3sh, radius[1][1]) + + if attach_bottom: + path_list = [[csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]] + else: + path_list = [[cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]] + self.path_list = path_list + + def get_path_list(self): + return self.path_list + + class BranchSphere: + def __init__(self, fieldmodule, coordinates, part1, radius): + sphere_shape = SphereShape.SPHERE_SHAPE_FULL + sphere_base = part1._ellipses[-1] + sphere_centre = sphere_base.centre + sphere_radius_3 = radius + axes = [sphere_base.majorAxis, sphere_base.minorAxis, + vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), + sphere_radius_3)] + elementsCountAcross = [part1._elementsCountAcrossMajor, part1._elementsCountAcrossMinor, 4] + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] + sphereBoxDerivatives = [1, 3, 2] + + sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, + 0, 1, 1.0, + sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, + boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) + + hemisphere = ShieldMesh3D(elementsCountAcross, 0) + + # get hemisphere nodes from both cylinder end and top of the sphere and mix them + btx = hemisphere.px + btd1 = hemisphere.pd1 + btd2 = hemisphere.pd2 + btd3 = hemisphere.pd3 + + hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives + hemisphere._boxMapping = sphere1._shield3D._boxMapping + hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping + hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor + hemisphere._xi_mapping = sphere1._shield3D._xi_mapping + hemisphere._xi_signs = sphere1._shield3D._xi_signs + + for n3 in range(elementsCountAcross[2] + 1): + for n2 in range(elementsCountAcross[0] + 1): + for n1 in range(elementsCountAcross[1] + 1): + if n3 > elementsCountAcross[2] // 2: + if sphere1._shield3D.px[n3][n2][n1]: + # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] + btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] + btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] + btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] + btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] + + # cylinder end + elif n3 == elementsCountAcross[2] // 2: + # find nodes on the triple line. Note that cylinder and sphere have a little bit different + # numbering for nodes on the triple line + n2c, n1c = n2, n1 + if n2 < 1 and n1 == n2: + n1c = 1 + elif n2 < 1 and n1 == elementsCountAcross[1] - n2: + n1c = elementsCountAcross[1] - 1 + elif n2 > 3: + if n1 == elementsCountAcross[1] - n2: + n1c = 1 + elif n1 == n2: + n1c = elementsCountAcross[1] - 1 + hemisphere.nodeId[n3][n2][n1] = part1._shield.nodeId[-1][n2c][n1c] + + # generate hemisphere extra nodes. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, + rangeOfRequiredElements) + + # generate himsphere elements. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, + rangeOfRequiredElements) + + self.sphere = hemisphere + + def get_sphere(self): + return self.sphere + + pn = PathNodes(shoulder_part, [[self.right_arm_radius]*2, [self.righ_wrist_radius]*2], self.right_arm_length, [4,4, self.rightArmNumberOfElements]) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.rightArmNumberOfElements], shoulder_part) + right_arm_cylinder = bc.get_cylinder() + + pn = PathNodes(shoulder_part_left, [[self.right_arm_radius]*2, [self.righ_wrist_radius]*2], self.right_arm_length, [4,4, self.rightArmNumberOfElements]) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.rightArmNumberOfElements], shoulder_part_left) + left_arm_cylinder = bc.get_cylinder() + + pn = PathNodes(neck_part, [[self.neck_radius2]*2, [self.neck_radius2]*2], self.neck_length, [4,4, self.neck_number_of_elements]) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.neck_number_of_elements], neck_part) + neck_cylinder = bc.get_cylinder() neck_cyliner_shield = neck_cylinder._shield - csh = neck_cyliner_shield.px[-1][neck_cylinder._elementsCountAcrossMajor//2][neck_cylinder._elementsCountAcrossMinor//2] - d1sh = neck_cyliner_shield.pd2[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] - d2sh = neck_cyliner_shield.pd1[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] - d3sh = neck_cyliner_shield.pd3[-1][neck_cylinder._elementsCountAcrossMajor // 2][neck_cylinder._elementsCountAcrossMinor // 2] - d2sh = vector.setMagnitude(d2sh, -self.neck_radius2) - d3sh = vector.setMagnitude(d3sh, self.neck_radius2) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, self.head_length/self.head_number_of_elements)], [1, 1]) - cw = vector.addVectors([cw, vector.setMagnitude([0.0, 1.0, 0.0], self.head_length/self.head_number_of_elements)], [1, 1]) - d1w = vector.setMagnitude(d1sh, self.head_length/self.head_number_of_elements) - d2w = vector.setMagnitude(d2sh, self.head_radius) - d3w = vector.setMagnitude(d3sh, self.neck_radius2) - path_list = [] - path_list.append([csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]) - path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + pn = PathNodes(neck_cyliner_shield, [[self.neck_radius2]*2, [self.head_radius, self.neck_radius2]], + self.head_length/self.head_number_of_elements, [4,4, 1]) + path_list = pn.get_path_list() + path_list[1][0] = vector.addVectors( + [path_list[1][0], vector.setMagnitude([0.0, -1.0, 0.0], + self.head_length/self.head_number_of_elements)], [1, 1]) + + cw, d1w, d2w = path_list[1][:3] + d3w = path_list[1][4] for ni in range(2, self.head_number_of_elements + 1): cw = vector.addVectors([cw, vector.setMagnitude(d1w, self.head_length/self.head_number_of_elements)], [1, 1]) if ni == 3: @@ -321,268 +325,52 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): else: path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + ss = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates, path_list, [4,4,5], neck_cyliner_shield) + head_cylinder = ss.cylinder - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': 5 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], path_list) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.head_number_of_elements) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(neck_cylinder._elementsCountAcrossMajor,neck_cylinder._elementsCountAcrossMinor, 0, 1, 1.0, - csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - head_cylinder = CylinderMesh(fieldmodule, coordinates, self.head_number_of_elements, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - head_cylinder.generateNodes(nodes, fieldmodule, coordinates, [1, self.head_number_of_elements + 1]) - - cylinder_shield = head_cylinder._shield - for n2 in range(neck_cylinder._elementsCountAcrossMajor + 1): - for n1 in range(neck_cylinder._elementsCountAcrossMinor + 1): - cylinder_shield.nodeId[0][n2][n1] = neck_cyliner_shield.nodeId[-1][n2][n1] - cylinder_shield.px[0][n2][n1] = neck_cyliner_shield.px[-1][n2][n1] - cylinder_shield.pd1[0][n2][n1] = neck_cyliner_shield.pd1[-1][n2][n1] - cylinder_shield.pd2[0][n2][n1] = neck_cyliner_shield.pd2[-1][n2][n1] - cylinder_shield.pd3[0][n2][n1] = neck_cyliner_shield.pd3[-1][n2][n1] - - head_cylinder.generateElements(mesh, fieldmodule, coordinates) - - - sphere_shape = SphereShape.SPHERE_SHAPE_FULL - sphere_base = head_cylinder._ellipses[-1] - sphere_centre = sphere_base.centre - sphere_radius_3 = self.head_radius - axes = [sphere_base.majorAxis, sphere_base.minorAxis, - vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), sphere_radius_3)] - elementsCountAcross = [head_cylinder._elementsCountAcrossMajor, head_cylinder._elementsCountAcrossMinor, 4] - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] - sphereBoxDerivatives = [1, 3, 2] - - sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, - 0, 1, 1.0, - sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, - boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) - - hemisphere = ShieldMesh3D(elementsCountAcross, 0) - - - - # get hemisphere nodes from both cylinder end and top of the sphere and mix them - btx = hemisphere.px - btd1 = hemisphere.pd1 - btd2 = hemisphere.pd2 - btd3 = hemisphere.pd3 - - hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives - hemisphere._boxMapping = sphere1._shield3D._boxMapping - hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping - hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor - hemisphere._xi_mapping = sphere1._shield3D._xi_mapping - hemisphere._xi_signs = sphere1._shield3D._xi_signs - - for n3 in range(elementsCountAcross[2] + 1): - for n2 in range(elementsCountAcross[0] + 1): - for n1 in range(elementsCountAcross[1] + 1): - if n3 > elementsCountAcross[2]//2: - if sphere1._shield3D.px[n3][n2][n1]: - # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] - btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] - btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] - btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] - btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] - - # cylinder end - elif n3 == elementsCountAcross[2]//2: - # find nodes on the triple line. Note that cylinder and sphere have a little bit different - # numbering for nodes on the triple line - n2c, n1c = n2, n1 - if n2 < 1 and n1 == n2: - n1c = 1 - elif n2 < 1 and n1 == elementsCountAcross[1] - n2: - n1c = elementsCountAcross[1] - 1 - elif n2 > 3: - if n1 == elementsCountAcross[1] - n2: - n1c = 1 - elif n1 == n2: - n1c = elementsCountAcross[1] - 1 - hemisphere.nodeId[n3][n2][n1] = head_cylinder._shield.nodeId[-1][n2c][n1c] - - # generate hemisphere extra nodes. - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] - nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) - nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, - rangeOfRequiredElements) - - # generate himsphere elements. - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] - elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) - elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, - rangeOfRequiredElements) - - - - csh = torso_upper_part.px[0][torso_upper_part._elementsCount[1]//2][torso_upper_part._elementsCount[0]//2] - d1sh = torso_upper_part.pd2[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] - d2sh = torso_upper_part.pd1[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] - d3sh = torso_upper_part.pd3[0][torso_upper_part._elementsCount[1] // 2][torso_upper_part._elementsCount[0] // 2] - d2sh = vector.setMagnitude(d2sh, -self.torso_radius) - d3sh = vector.setMagnitude(d3sh, self.torso_radius) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, -self.lower_torso_length)], [1, 1]) - d1w = vector.setMagnitude(d1sh, self.lower_torso_length/self.lower_torso_number_of_elements) - d2w = vector.setMagnitude(d2sh, self.lower_torso_radii[0]) - d3w = vector.setMagnitude(d3sh, self.lower_torso_radii[1]) - - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], - [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], - ]) - }) - - cylinderCentralPath = CylinderCentralPath(self._region, centralPath, self.lower_torso_number_of_elements) - - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - - base = CylinderEnds(torso_upper_part._elementsCount[1], torso_upper_part._elementsCount[0], 0, 1, 1.0, - csh, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - lower_torso_cylinder = CylinderMesh(fieldmodule, coordinates, self.lower_torso_number_of_elements, base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - lower_torso_cylinder.generateNodes(nodes, fieldmodule, coordinates, [0, self.lower_torso_number_of_elements]) - - cylinder_shield = lower_torso_cylinder._shield - for n2 in range(torso_upper_part._elementsCount[1] + 1): - for n1 in range(torso_upper_part._elementsCount[0] + 1): - cylinder_shield.nodeId[-1][n2][n1] = torso_upper_part.nodeId[0][n2][n1] - cylinder_shield.px[-1][n2][n1] = torso_upper_part.px[0][n2][n1] - cylinder_shield.pd1[-1][n2][n1] = torso_upper_part.pd1[0][n2][n1] - cylinder_shield.pd2[-1][n2][n1] = torso_upper_part.pd2[0][n2][n1] - cylinder_shield.pd3[-1][n2][n1] = torso_upper_part.pd3[0][n2][n1] - - lower_torso_cylinder.generateElements(mesh, fieldmodule, coordinates) + sph = BranchSphere(fieldmodule, coordinates, head_cylinder, self.head_radius) + pn = PathNodes(torso_upper_part, [[self.torso_radius]*2, self.lower_torso_radii], self.lower_torso_length, [4,4, self.lower_torso_number_of_elements], attach_bottom=False) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates, path_list, [4, 4, self.lower_torso_number_of_elements], torso_upper_part, attach_bottom=False) + lower_torso_cylinder = bc.get_cylinder() smoothing = DerivativeSmoothing(self._region, coordinates) smoothing.smooth(True) del smoothing - - # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) - # - # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) - # - # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] - # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] - # - # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] - # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] - # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] - # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] - # d11 = vector.addVectors([p1, centre], [1, -1]) - # d21 = vector.addVectors([outer_point, centre], [1, -1]) - # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) - - - # centralPath = ScaffoldPackage(MeshType_1d_path1, { - # 'scaffoldSettings': { - # 'Coordinate dimensions': 3, - # 'D2 derivatives': True, - # 'D3 derivatives': True, - # 'Length': 3.0, - # 'Number of elements': 4 - # }, - # 'meshEdits': exnodeStringFromNodeValues( - # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] - # ]) - # }) - # - # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) - # - # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - # - # base = CylinderEnds(4, 4, 0, 1, 1.0, - # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - # cylinderCentralPath.minorRadii[0]) - # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, - # cylinderShape=cylinderShape, - # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - - # joining_torso = JoiningTorso([4, 4, 1]) - # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) - # print(joining_torso.nodeId) - # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) - # - # - # torso_part = torso_cylinder._shield - def _get_node_params(self): """ :return: """ + class CylinderCurves: + def __init__(self, bottom_curves, top_curves): + self.curves = [bottom_curves, top_curves] + + class EllipseCurves: + def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): + x_curve2[0] = [c for c in x_curve1[0]] + self.xc1 = x_curve1 + self.d1c1 = d1_curve1 + self.xc2 = x_curve2 + self.d1c2 = d1_curve2 + armpit = self.armpit - x_bottom_base_centre = [0.0, 0.0, 0.0] - x_bottom_base_curve1 = [self.torso_radius, 0.0, 0.0] - x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] - d1_bottom_base_curve1 = [[self.torso_radius/self._elementsCount[0], 0.0, 0.0], - [self.torso_radius/self._elementsCount[0], 0.0, 0.0]] - d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - x_bottom_end_centre = [0.0, 0.0, 1.4] - x_bottom_end_curve1 = armpit - x_bottom_end_curve2 = [0.0, 1.0, 1.4] - d1_bottom_end_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], - [0.5*0.7071, 0.0, -0.5*0.7071]] - d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - - nodeparams1 = [[x_bottom_base_centre, x_bottom_base_curve1, x_bottom_base_curve2, d1_bottom_base_curve1, - d1_bottom_base_curve2], - [x_bottom_end_centre, x_bottom_end_curve1, x_bottom_end_curve2, d1_bottom_end_curve1, - d1_bottom_end_curve2]] + + bc = EllipseCurves([[0.0, 0.0, 0.0], [self.torso_radius, 0.0, 0.0]], + [[self.torso_radius / self._elementsCount[0], 0.0, 0.0]]*2, + [[0.0, 0.0, 0.0], [0.0, self.torso_radius, 0.0]], + [[0.0, 1/self._elementsCount[1], 0.0]]*2) + + tc = EllipseCurves([[0.0, 0.0, 1.4], armpit], + [[1 / self._elementsCount[0], 0.0, 0.0], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[0.0, 0.0, 1.4], [0.0, 1.0, 1.4]], + [[0.0, 1 / self._elementsCount[1], 0.0]]*2) + + base_c = CylinderCurves(bc, tc) x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] - x_shoulder_base_curve1 = armpit - x_shoulder_base_curve2 = [0.75, 1.0, self.shoulder_height] - d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] kv = [0.0, 1.0, 0.0] cv = [self.right_shoulder_length, 0.0, 0.0] cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) @@ -591,12 +379,15 @@ def _get_node_params(self): ======= cevunit = vector.normalise(cev) ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) +<<<<<<< HEAD >>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) x_shoulder_end_centre = ce # x_shoulder_end_curve1 = [1.7, 0.0, self.shoulder_height - self.left_arm_radius] +======= +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) - # x_shoulder_end_curve2 = [1.7, self.left_arm_radius, self.shoulder_height] x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) +<<<<<<< HEAD # d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1]), vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1])] @@ -610,49 +401,55 @@ def _get_node_params(self): d1_shoulder_base_curve2], [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, d1_shoulder_end_curve2]] +======= + d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 + + bc = EllipseCurves([[0.75, 0.0, self.shoulder_height], armpit], + [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[0.75, 0.0, self.shoulder_height], [0.75, 1.0, self.shoulder_height]], + [[0.0, 1 / self._elementsCount[0], 0.0]]*2) + tc = EllipseCurves([ce, x_shoulder_end_curve1], d1_shoulder_end_curve1, + [ce, x_shoulder_end_curve2], d1_shoulder_end_curve2) + shoulder_lc = CylinderCurves(bc, tc) +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) x_shoulder_base_centre = [-0.75, 0.0, self.shoulder_height] - x_shoulder_base_curve2 = [-armpit[0], armpit[1], armpit[2]] - x_shoulder_base_curve1 = [-0.75, 1.0, self.shoulder_height] - d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] kv = [0.0, 1.0, 0.0] cv = [-self.right_shoulder_length, 0.0, 0.0] cev = vector.rotateVectorAroundVector(cv, kv, -self.left_arm_angle) ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) - x_shoulder_end_centre = ce - # x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius)], [1, 1]) - # x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.left_arm_radius] x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) - # x_shoulder_end_curve1 = [-1.7, self.left_arm_radius, self.shoulder_height] - d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1]), - vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1])] - # d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] - d1_shoulder_end_curve1 = [[-0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] + d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve1 = [[-0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 - nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, - d1_shoulder_base_curve2], - [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, - d1_shoulder_end_curve2]] + bc = EllipseCurves([[-0.75, 0.0, self.shoulder_height], [-0.75, 1.0, self.shoulder_height]], + [[-0.0, 1 / self._elementsCount[0], 0.0]]*2, + [[-0.75, 0.0, self.shoulder_height], [-armpit[0], armpit[1], armpit[2]]], + [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]]) + tc = EllipseCurves([ce, x_shoulder_end_curve1], d1_shoulder_end_curve1, + [ce, x_shoulder_end_curve2], d1_shoulder_end_curve2) + shoulder_rc = CylinderCurves(bc, tc) x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] - d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] + d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0]]*2 d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] x_neck_end_centre = [0.0, 0.0, self.neck_height] x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] - d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] - d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] + d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0]]*2 + d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0]]*2 - nodeparams4 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, - d1_neck_base_curve2], - [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, - d1_neck_end_curve2]] + bc = EllipseCurves([x_neck_base_centre, x_neck_base_curve1], d1_neck_base_curve1, + [x_neck_base_centre, x_neck_base_curve2], d1_neck_base_curve2) + tc = EllipseCurves([x_neck_end_centre, x_neck_end_curve1], d1_neck_end_curve1, + [x_neck_end_centre, x_neck_end_curve2], d1_neck_end_curve2) + neck_c = CylinderCurves(bc, tc) - return nodeparams1, nodeparams2, nodeparams3, nodeparams4 + return base_c, shoulder_lc, shoulder_rc, neck_c def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): """ @@ -1531,11 +1328,15 @@ class BaseLeg: """ Base case for creating a child """ +<<<<<<< HEAD <<<<<<< HEAD def __init__(self, elementsCount, nodeparams): ======= def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_left=False): >>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) +======= + def __init__(self, elementsCount, cyl_curves, shoulder_right=False, shoulder_left=False): +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) """ :param fieldmodule: @@ -1545,7 +1346,6 @@ def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_lef """ elementsCount = [4, 4, 2] self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] - self.nodeparams = nodeparams self._shoulder = False self._shoulder_left = False self._neck = False @@ -1556,13 +1356,15 @@ def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_lef self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - self.generateBaseLeg(nodeparams) + self.generateBaseLeg(cyl_curves.curves) - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + bc = cyl_curves.curves[0] + tc = cyl_curves.curves[1] + n, d = geometry.get_plane_normal_vector_and_distance(bc.xc1[0], bc.xc1[1], tc.xc1[0]) plane = [n[0], n[1], n[2], d] mirrore = Mirror(plane) if shoulder_left: - mirror0 = Mirror([0.0, 0.0, 1.0, nodeparams[0][0][2]]) + mirror0 = Mirror([0.0, 0.0, 1.0, bc.xc1[0][2]]) for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): for n3 in range(elementsCount[2]+1): if shoulder_left and n3 == 0: @@ -1579,7 +1381,7 @@ def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_lef self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + n, d = geometry.get_plane_normal_vector_and_distance(bc.xc1[0], bc.xc2[1], tc.xc1[0]) plane = [n[0], n[1], n[2], d] <<<<<<< HEAD mirror = Mirror(plane) @@ -1588,7 +1390,7 @@ def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_lef ======= mirrore = Mirror(plane) if shoulder_right: - mirror0 = Mirror([0.0, 0.0, 1.0, nodeparams[0][0][2]]) + mirror0 = Mirror([0.0, 0.0, 1.0, bc.xc1[0][2]]) for n2 in range(elementsCount[1]+1): for n3 in range(elementsCount[2]+1): if shoulder_right and n3 == 0: @@ -1609,41 +1411,61 @@ def __init__(self, elementsCount, nodeparams, shoulder_right=False, shoulder_lef self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) +<<<<<<< HEAD +======= + + # sample in between ellipses + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + elementsCountOut = 2 + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + if btx[0][n2][n1]: + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves( + [btx[0][n2][n1], btx[self._elementsCount[2]][n2][n1]], + [btd2[0][n2][n1], btd2[self._elementsCount[2]][n2][n1]], + elementsCountOut) + td1 = interpolateSampleCubicHermite( + [btd1[0][n2][n1], btd1[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [btd3[0][n2][n1], btd3[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + + for n3 in range(1, self._elementsCount[2]): + n3i = n3 + self.px[n3][n2][n1] = tx[n3i] + self.pd1[n3][n2][n1] = td1[n3i] + self.pd2[n3][n2][n1] = td2[n3i] + self.pd3[n3][n2][n1] = td3[n3i] + +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) self._elementsCount = elementsCount - def generateBaseLeg(self, nodeparams): + def generateBaseLeg(self, surface_curves): """ Generate base leg that is a cylinder generated from cylinder ends. :return: """ - bottomnodeparams = nodeparams[0] - topnodeparams = nodeparams[1] - self.genetateBottomSurface(bottomnodeparams) - self.generateTopSurface(topnodeparams) + bottom_curves = surface_curves[0] + top_curves = surface_curves[1] + self.generate_surface(bottom_curves, 0) + self.generate_surface(top_curves, self._elementsCount[2]) self.generateMiddleLevels() self.smoothd2() - def genetateBottomSurface(self, bottomnodeparams): - """ - Use major and minor curves to generate the ellipse - :return: - """ - centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, 0) - - def generateTopSurface(self, topnodeparams): + def generate_surface(self, curves, n3): """ :return: """ - centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + centre = curves.xc1[0] + txc1, td1c1 = self.generate1DPath(curves.xc1, curves.d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath(curves.xc2, curves.d1c2, self._elementsCount[1]) ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + self.copyEllipseNodesToBifurcation(ellipse, n3) def generateMiddleLevels(self): """ @@ -1654,6 +1476,7 @@ def generateMiddleLevels(self): btd1 = self.pd1 btd2 = self.pd2 btd3 = self.pd3 +<<<<<<< HEAD # generate the armpit curves. elementsCountOut = 2 txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], @@ -1687,6 +1510,33 @@ def generateMiddleLevels(self): txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) self.copyEllipseNodesToBifurcation(ellipse, n3) +======= + + # generate the armpit curves. + elementsCountOut = 2 + + # sample in between ellipses + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves( + [btx[0][n2][n1], btx[self._elementsCount[2]][n2][n1]], + [btd2[0][n2][n1], btd2[self._elementsCount[2]][n2][n1]], + elementsCountOut) + td1 = interpolateSampleCubicHermite( + [btd1[0][n2][n1], btd1[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [btd3[0][n2][n1], btd3[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + + for n3 in range(1, self._elementsCount[2]): + n3i = n3 + self.px[n3][n2][n1] = tx[n3i] + self.pd1[n3][n2][n1] = td1[n3i] + self.pd2[n3][n2][n1] = td2[n3i] + self.pd3[n3][n2][n1] = td3[n3i] +>>>>>>> 9619665 (Modify axes and clean the code and make some classes) def smoothd2(self): """ @@ -1732,8 +1582,11 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] - majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] - minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] + centre_d1c1 = [c for c in td1c1[0]] + centre_d1c2 = [c for c in td1c2[0]] + majorAxis = [c*self._elementsCount[0] for c in centre_d1c2] + minorAxis = [-c*self._elementsCount[1] for c in centre_d1c1] + elementsCountAcrossShell = 0 elementsCountAcrossTransition = 1 shellProportion = 1.0 @@ -1747,11 +1600,14 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): shield = ellipse.getShield() ellipse.generateBase1DMesh(0) + # Modify x and d1 for nodes on the end of curve 1 and 2. ellipse.px[self._elementsCount[1]][0] = txc1[-1] ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] ellipse.px[0][self._elementsCount[0]] = txc2[-1] ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] + # Bend the surface according to its new curves + # Modify x and d1 for the surface perimeter nx = [] nd1 = [] for n in range(elementsCountAround + 1): @@ -1768,7 +1624,7 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) delnormag = vector.dotproduct(delta, normal) delnor = vector.scaleVector(normal, delnormag) - if 0 Date: Fri, 22 Apr 2022 03:54:01 +1200 Subject: [PATCH 18/38] Separate arms from upper torso --- .../meshtype_3d_solidbifurcation2.py | 60 ++- src/scaffoldmaker/utils/bifurcation3d2.py | 469 +++++++++--------- 2 files changed, 278 insertions(+), 251 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index fadcf34f..977df439 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -4,19 +4,17 @@ """ from __future__ import division -import math import copy from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates +from opencmiss.zinc.node import Node +from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import MeshType_1d_stickman1, extractPathParametersFromRegion from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base -from scaffoldmaker.utils.meshrefinement import MeshRefinement from scaffoldmaker.scaffoldpackage import ScaffoldPackage -from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 -from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import MeshType_1d_stickman1 -from opencmiss.zinc.node import Node -from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh -from scaffoldmaker.meshtypes.meshtype_1d_stickman1 import extractPathParametersFromRegion from scaffoldmaker.utils import vector +from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh, BranchType, PathNodes +from scaffoldmaker.utils.meshrefinement import MeshRefinement class MeshType_3d_solidbifurcation2(Scaffold_base): @@ -292,15 +290,49 @@ def generateBaseMesh(region, options): if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: left_arm_angle = -left_arm_angle - # bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, - # neck_radius, shoulder_height, neck_height, right_arm_angle, right_arm_length, - # shoulder_joint, armpit, neck_shoulder, shoulder_point, shoulder_start) bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, - right_shoulder_length, right_arm_length, rightArmNumberOfElements, - righ_wrist_radius, neck_radius2, neck_length, neck_number_of_elements, - head_length, head_number_of_elements, head_radius, armpit, lower_torso_length, - lower_torso_number_of_elements, lower_torso_radii) + right_shoulder_length, armpit) + + bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], + right_arm_length, [4, 4, rightArmNumberOfElements], + branch_type=BranchType.LEFT_ARM) + bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], + right_arm_length, [4, 4, rightArmNumberOfElements], + branch_type=BranchType.RIGHT_ARM) + neck_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2]*2, [neck_radius2]*2], neck_length, + [4,4, neck_number_of_elements], branch_type=BranchType.NECK) + + neck_cyliner_shield = neck_cylinder._shield + pn = PathNodes(neck_cyliner_shield, [[neck_radius2]*2, [head_radius, neck_radius2]], + head_length/head_number_of_elements, [4,4, 1]) + path_list = pn.get_path_list() + path_list[1][0] = vector.addVectors( + [path_list[1][0], vector.setMagnitude([0.0, -1.0, 0.0], + head_length/head_number_of_elements)], [1, 1]) + + cw, d1w, d2w = path_list[1][:3] + d3w = path_list[1][4] + for ni in range(2, head_number_of_elements + 1): + cw = vector.addVectors([cw, vector.setMagnitude(d1w, head_length/head_number_of_elements)], [1, 1]) + if ni == 3: + path_list.append([cw, d1w, vector.scaleVector(d2w, 1.1), [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + else: + path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + + head_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], + head_length/head_number_of_elements, + [4,4, head_number_of_elements], path_list=path_list, + part1=neck_cyliner_shield, branch_type=4) + + cap = bifurcation1.create_branch_cap(head_cylinder, head_radius) + bifurcation1.smooth_all_derivatives() + + lower_torso_cylinder = bifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], + lower_torso_length, + [4,4, lower_torso_number_of_elements], + part1=bifurcation1._torso_upper_part, branch_type=4, + attach_bottom=False) annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index ea1301c3..7cf6ceea 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -1,28 +1,191 @@ """ Utility functions for generating a 3-D solid bifurcation. """ -import copy from enum import Enum -from scaffoldmaker.utils import vector, geometry -import math -from opencmiss.zinc.field import Field from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier -from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode -from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ - smoothCubicHermiteDerivativesLine, interpolateSampleLinear -from opencmiss.zinc.node import Node -from scaffoldmaker.utils.mirror import Mirror -from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion -from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh -from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite -from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds from opencmiss.zinc.element import Element -from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from opencmiss.zinc.field import Field +from opencmiss.zinc.node import Node from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.utils import vector, geometry +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds,\ + CylinderMesh from scaffoldmaker.utils.derivativemoothing import DerivativeSmoothing -from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues -from scaffoldmaker.utils.spheremesh import SphereMesh, SphereShape +from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds +from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite +from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ + smoothCubicHermiteDerivativesLine +from scaffoldmaker.utils.mirror import Mirror from scaffoldmaker.utils.shieldmesh import ShieldMesh3D +from scaffoldmaker.utils.spheremesh import SphereMesh, SphereShape +from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues + + +class PathNodes: + def __init__(self, part1, radius, length, elements_count, attach_bottom=True): + if attach_bottom: + n3 = -1 + sc = 1 + else: + n3 = 0 + sc = -1 + csh = part1.px[n3][elements_count[1] // 2][elements_count[0] // 2] + d1sh = part1.pd2[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = part1.pd1[n3][elements_count[1] // 2][elements_count[0] // 2] + d3sh = part1.pd3[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = vector.setMagnitude(d2sh, -radius[0][0]) + d3sh = vector.setMagnitude(d3sh, radius[0][1]) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, sc * length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, length / elements_count[2]) + d2w = vector.setMagnitude(d2sh, radius[1][0]) + d3w = vector.setMagnitude(d3sh, radius[1][1]) + + if attach_bottom: + path_list = [[csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]] + else: + path_list = [[cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]] + self.path_list = path_list + + def get_path_list(self): + return self.path_list + + +class BranchCylinder: + def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, + attach_bottom=True): + if attach_bottom: + n3, n3p = 0, -1 + node_ranges = [1, elements_count[2] + 1] + else: + n3, n3p = -1, 0 + node_ranges = [0, elements_count[2]] + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': len(path_list) - 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, + Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], + path_list) + }) + cylinderCentralPath = CylinderCentralPath(region, centralPath, elements_count[2]) + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + centre = path_list[0][0] + base = CylinderEnds(elements_count[1], elements_count[0], 0, 1, 1.0, + centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + cylinder = CylinderMesh(fieldmodule, coordinates, elements_count[2], base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + cylinder.generateNodes(nodes, fieldmodule, coordinates, node_ranges) + + cylinder_shield = cylinder._shield + for n2 in range(elements_count[1] + 1): + for n1 in range(elements_count[0] + 1): + cylinder_shield.nodeId[n3][n2][n1] = part1.nodeId[n3p][n2][n1] + cylinder_shield.px[n3][n2][n1] = part1.px[n3p][n2][n1] + cylinder_shield.pd1[n3][n2][n1] = part1.pd1[n3p][n2][n1] + cylinder_shield.pd2[n3][n2][n1] = part1.pd2[n3p][n2][n1] + cylinder_shield.pd3[n3][n2][n1] = part1.pd3[n3p][n2][n1] + + cylinder.generateElements(mesh, fieldmodule, coordinates) + self.cylinder = cylinder + + def get_cylinder(self): + return self.cylinder + + +class BranchCap: + def __init__(self, fieldmodule, coordinates, mesh, nodes, part1, radius): + sphere_shape = SphereShape.SPHERE_SHAPE_FULL + sphere_base = part1._ellipses[-1] + sphere_centre = sphere_base.centre + sphere_radius_3 = radius + axes = [sphere_base.majorAxis, sphere_base.minorAxis, + vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), + sphere_radius_3)] + elementsCountAcross = [part1._elementsCountAcrossMajor, part1._elementsCountAcrossMinor, 4] + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] + sphereBoxDerivatives = [1, 3, 2] + + sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, + 0, 1, 1.0, + sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, + boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) + + hemisphere = ShieldMesh3D(elementsCountAcross, 0) + + # get hemisphere nodes from both cylinder end and top of the sphere and mix them + btx = hemisphere.px + btd1 = hemisphere.pd1 + btd2 = hemisphere.pd2 + btd3 = hemisphere.pd3 + + hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives + hemisphere._boxMapping = sphere1._shield3D._boxMapping + hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping + hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor + hemisphere._xi_mapping = sphere1._shield3D._xi_mapping + hemisphere._xi_signs = sphere1._shield3D._xi_signs + + for n3 in range(elementsCountAcross[2] + 1): + for n2 in range(elementsCountAcross[0] + 1): + for n1 in range(elementsCountAcross[1] + 1): + if n3 > elementsCountAcross[2] // 2: + if sphere1._shield3D.px[n3][n2][n1]: + # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] + btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] + btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] + btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] + btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] + + # cylinder end + elif n3 == elementsCountAcross[2] // 2: + # find nodes on the triple line. Note that cylinder and sphere have a little bit different + # numbering for nodes on the triple line + n2c, n1c = n2, n1 + if n2 < 1 and n1 == n2: + n1c = 1 + elif n2 < 1 and n1 == elementsCountAcross[1] - n2: + n1c = elementsCountAcross[1] - 1 + elif n2 > 3: + if n1 == elementsCountAcross[1] - n2: + n1c = 1 + elif n1 == n2: + n1c = elementsCountAcross[1] - 1 + hemisphere.nodeId[n3][n2][n1] = part1._shield.nodeId[-1][n2c][n1c] + + # generate hemisphere extra nodes. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, + rangeOfRequiredElements) + + # generate himsphere elements. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, + rangeOfRequiredElements) + + self.sphere = hemisphere + + def get_sphere(self): + return self.sphere + + +class BranchType(Enum): + RIGHT_ARM = 1 + NECK = 2 + LEFT_ARM = 3 class BifurcationMesh: @@ -30,11 +193,8 @@ class BifurcationMesh: Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, - shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, - right_arm_length, rightArmNumberOfElements, righ_wrist_radius, neck_radius2, neck_length, - neck_number_of_elements, head_length, head_number_of_elements, head_radius, armpit, - lower_torso_length, lower_torso_number_of_elements, lower_torso_radii): + def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, + shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -48,27 +208,24 @@ def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radi self.left_arm_radius = left_arm_radius self.right_arm_radius = right_arm_radius self.neck_radius = neck_radius - self.neck_radius2 = neck_radius2 - self.neck_length = neck_length - self.head_length = head_length - self.head_number_of_elements = head_number_of_elements - self.head_radius = head_radius - self.neck_number_of_elements = neck_number_of_elements self.shoulder_height = shoulder_height self.neck_height = neck_height self.right_arm_angle = right_arm_angle self.left_arm_angle = left_arm_angle self.right_shoulder_length = right_shoulder_length - self.right_arm_length = right_arm_length - self.rightArmNumberOfElements = rightArmNumberOfElements - self.righ_wrist_radius = righ_wrist_radius self.armpit = armpit - self.lower_torso_length = lower_torso_length - self.lower_torso_number_of_elements = lower_torso_number_of_elements - self.lower_torso_radii = lower_torso_radii + self._coordinates = coordinates + self._fieldmodule = fieldmodule + self._nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + self._mesh = fieldmodule.findMeshByDimension(3) - self.createBifurcationMesh3d(fieldModule, coordinates) + self._torso_upper_part = None + self._shoulder_part = None + self._shoulder_part_left = None + self._neck_part = None + + self.createBifurcationMesh3d(fieldmodule, coordinates) def createBifurcationMesh3d(self, fieldmodule, coordinates): """ @@ -85,14 +242,14 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ # 'createCylinderMesh3d: Invalid cylinder mode.' - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - mesh = fieldmodule.findMeshByDimension(3) - + nodes = self._nodes + mesh = self._mesh base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() torso_upper_part = BaseLeg(self._elementsCount, base_c) self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) + self._torso_upper_part = torso_upper_part <<<<<<< HEAD <<<<<<< HEAD @@ -108,6 +265,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) self.join_shoulder_to_bottom_part(shoulder_part, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) + self._shoulder_part = shoulder_part joining_box = JoiningBox([1, 4, 1], self.shoulder_height) self.generateNodes(nodes, fieldmodule, coordinates, joining_box) @@ -120,6 +278,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) self.join_shoulder_to_bottom_part(shoulder_part_left, torso_upper_part, 1) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) + self._shoulder_part_left = shoulder_part_left neck_part = BaseLeg(self._elementsCount, neck_c) neck_part._neck = True @@ -127,6 +286,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateNodes(nodes, fieldmodule, coordinates, neck_part) self.join_neck_to_torso(neck_part, shoulder_part, shoulder_part_left) self.generateElements(mesh, fieldmodule, coordinates, neck_part) + self._neck_part = neck_part joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) @@ -137,205 +297,31 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) - class BranchCylinder: - def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, attach_bottom=True): - if attach_bottom: - n3, n3p = 0, -1 - node_ranges = [1, elements_count[2] + 1] - else: - n3, n3p = -1, 0 - node_ranges = [0, elements_count[2]] - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': len(path_list) - 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, - Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], - path_list) - }) - cylinderCentralPath = CylinderCentralPath(region, centralPath, elements_count[2]) - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - centre = path_list[0][0] - base = CylinderEnds(elements_count[1], elements_count[0], 0, 1, 1.0, - centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - cylinderCentralPath.minorRadii[0]) - cylinder = CylinderMesh(fieldmodule, coordinates, elements_count[2], base, - cylinderShape=cylinderShape, - cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, - rangeOfRequiredElementsAlong=[-1, -1]) - - cylinder.generateNodes(nodes, fieldmodule, coordinates, node_ranges) - - cylinder_shield = cylinder._shield - for n2 in range(elements_count[1] + 1): - for n1 in range(elements_count[0] + 1): - cylinder_shield.nodeId[n3][n2][n1] = part1.nodeId[n3p][n2][n1] - cylinder_shield.px[n3][n2][n1] = part1.px[n3p][n2][n1] - cylinder_shield.pd1[n3][n2][n1] = part1.pd1[n3p][n2][n1] - cylinder_shield.pd2[n3][n2][n1] = part1.pd2[n3p][n2][n1] - cylinder_shield.pd3[n3][n2][n1] = part1.pd3[n3p][n2][n1] - - cylinder.generateElements(mesh, fieldmodule, coordinates) - self.cylinder = cylinder - - def get_cylinder(self): - return self.cylinder - - class PathNodes: - def __init__(self, part1, radius, length, elements_count, attach_bottom=True): - if attach_bottom: - n3 = -1 - sc = 1 - else: - n3 = 0 - sc = -1 - csh = part1.px[n3][elements_count[1] // 2][elements_count[0] // 2] - d1sh = part1.pd2[n3][elements_count[1] // 2][elements_count[0] // 2] - d2sh = part1.pd1[n3][elements_count[1] // 2][elements_count[0] // 2] - d3sh = part1.pd3[n3][elements_count[1] // 2][elements_count[0] // 2] - d2sh = vector.setMagnitude(d2sh, -radius[0][0]) - d3sh = vector.setMagnitude(d3sh, radius[0][1]) - cw = vector.addVectors([csh, vector.setMagnitude(d1sh, sc*length)], [1, 1]) - d1w = vector.setMagnitude(d1sh, length / elements_count[2]) - d2w = vector.setMagnitude(d2sh, radius[1][0]) - d3w = vector.setMagnitude(d3sh, radius[1][1]) - - if attach_bottom: - path_list = [[csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], - [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]] - else: - path_list = [[cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], - [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]] - self.path_list = path_list - - def get_path_list(self): - return self.path_list - - class BranchSphere: - def __init__(self, fieldmodule, coordinates, part1, radius): - sphere_shape = SphereShape.SPHERE_SHAPE_FULL - sphere_base = part1._ellipses[-1] - sphere_centre = sphere_base.centre - sphere_radius_3 = radius - axes = [sphere_base.majorAxis, sphere_base.minorAxis, - vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), - sphere_radius_3)] - elementsCountAcross = [part1._elementsCountAcrossMajor, part1._elementsCountAcrossMinor, 4] - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] - sphereBoxDerivatives = [1, 3, 2] - - sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, - 0, 1, 1.0, - sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, - boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) - - hemisphere = ShieldMesh3D(elementsCountAcross, 0) - - # get hemisphere nodes from both cylinder end and top of the sphere and mix them - btx = hemisphere.px - btd1 = hemisphere.pd1 - btd2 = hemisphere.pd2 - btd3 = hemisphere.pd3 - - hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives - hemisphere._boxMapping = sphere1._shield3D._boxMapping - hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping - hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor - hemisphere._xi_mapping = sphere1._shield3D._xi_mapping - hemisphere._xi_signs = sphere1._shield3D._xi_signs - - for n3 in range(elementsCountAcross[2] + 1): - for n2 in range(elementsCountAcross[0] + 1): - for n1 in range(elementsCountAcross[1] + 1): - if n3 > elementsCountAcross[2] // 2: - if sphere1._shield3D.px[n3][n2][n1]: - # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] - btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] - btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] - btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] - btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] - - # cylinder end - elif n3 == elementsCountAcross[2] // 2: - # find nodes on the triple line. Note that cylinder and sphere have a little bit different - # numbering for nodes on the triple line - n2c, n1c = n2, n1 - if n2 < 1 and n1 == n2: - n1c = 1 - elif n2 < 1 and n1 == elementsCountAcross[1] - n2: - n1c = elementsCountAcross[1] - 1 - elif n2 > 3: - if n1 == elementsCountAcross[1] - n2: - n1c = 1 - elif n1 == n2: - n1c = elementsCountAcross[1] - 1 - hemisphere.nodeId[n3][n2][n1] = part1._shield.nodeId[-1][n2c][n1c] - - # generate hemisphere extra nodes. - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] - nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) - nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, - rangeOfRequiredElements) - - # generate himsphere elements. - rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] - elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) - elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, - rangeOfRequiredElements) - - self.sphere = hemisphere - - def get_sphere(self): - return self.sphere - - pn = PathNodes(shoulder_part, [[self.right_arm_radius]*2, [self.righ_wrist_radius]*2], self.right_arm_length, [4,4, self.rightArmNumberOfElements]) - path_list = pn.get_path_list() - bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.rightArmNumberOfElements], shoulder_part) - right_arm_cylinder = bc.get_cylinder() - - pn = PathNodes(shoulder_part_left, [[self.right_arm_radius]*2, [self.righ_wrist_radius]*2], self.right_arm_length, [4,4, self.rightArmNumberOfElements]) - path_list = pn.get_path_list() - bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.rightArmNumberOfElements], shoulder_part_left) - left_arm_cylinder = bc.get_cylinder() - - pn = PathNodes(neck_part, [[self.neck_radius2]*2, [self.neck_radius2]*2], self.neck_length, [4,4, self.neck_number_of_elements]) - path_list = pn.get_path_list() - bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates,path_list,[4,4,self.neck_number_of_elements], neck_part) - neck_cylinder = bc.get_cylinder() - - neck_cyliner_shield = neck_cylinder._shield - pn = PathNodes(neck_cyliner_shield, [[self.neck_radius2]*2, [self.head_radius, self.neck_radius2]], - self.head_length/self.head_number_of_elements, [4,4, 1]) - path_list = pn.get_path_list() - path_list[1][0] = vector.addVectors( - [path_list[1][0], vector.setMagnitude([0.0, -1.0, 0.0], - self.head_length/self.head_number_of_elements)], [1, 1]) - - cw, d1w, d2w = path_list[1][:3] - d3w = path_list[1][4] - for ni in range(2, self.head_number_of_elements + 1): - cw = vector.addVectors([cw, vector.setMagnitude(d1w, self.head_length/self.head_number_of_elements)], [1, 1]) - if ni == 3: - path_list.append([cw, d1w, vector.scaleVector(d2w, 1.1), [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) - else: - path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) + def create_branch_cylinder(self, radius, length, number_of_elements, path_list=None, + part1=None, attach_bottom=True, branch_type=BranchType.LEFT_ARM): + if branch_type == BranchType.LEFT_ARM: + part1 = self._shoulder_part + elif branch_type == BranchType.RIGHT_ARM: + part1 = self._shoulder_part_left + elif branch_type == BranchType.NECK: + part1 = self._neck_part - ss = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates, path_list, [4,4,5], neck_cyliner_shield) - head_cylinder = ss.cylinder + if not path_list: + pn = PathNodes(part1, radius, length, number_of_elements, attach_bottom=attach_bottom) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, number_of_elements, part1, attach_bottom=attach_bottom) + cylinder = bc.get_cylinder() - sph = BranchSphere(fieldmodule, coordinates, head_cylinder, self.head_radius) + return cylinder - pn = PathNodes(torso_upper_part, [[self.torso_radius]*2, self.lower_torso_radii], self.lower_torso_length, [4,4, self.lower_torso_number_of_elements], attach_bottom=False) - path_list = pn.get_path_list() - bc = BranchCylinder(self._region, mesh, nodes, fieldmodule, coordinates, path_list, [4, 4, self.lower_torso_number_of_elements], torso_upper_part, attach_bottom=False) - lower_torso_cylinder = bc.get_cylinder() + def create_branch_cap(self, part1, radius): + cap = BranchCap(self._fieldmodule, self._coordinates, self._mesh, self._nodes, part1, radius) - smoothing = DerivativeSmoothing(self._region, coordinates) + return cap + + def smooth_all_derivatives(self): + smoothing = DerivativeSmoothing(self._region, self._coordinates) smoothing.smooth(True) del smoothing @@ -373,6 +359,7 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] kv = [0.0, 1.0, 0.0] cv = [self.right_shoulder_length, 0.0, 0.0] +<<<<<<< HEAD cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) <<<<<<< HEAD ce = vector.addVectors([cev, [0.0, 0.0, self.shoulder_height]], [1, 1]) @@ -403,6 +390,14 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): d1_shoulder_end_curve2]] ======= d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius/self._elementsCount[1])]*2 +======= + cev = vector.rotateVectorAroundVector(cv, kv, self.left_arm_angle) + cevunit = vector.normalise(cev) + ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) + x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius)], [1, 1]) + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) + d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius/self._elementsCount[1])]*2 +>>>>>>> 5931d2a (Separate arms from upper torso) d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 bc = EllipseCurves([[0.75, 0.0, self.shoulder_height], armpit], @@ -417,12 +412,12 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): x_shoulder_base_centre = [-0.75, 0.0, self.shoulder_height] kv = [0.0, 1.0, 0.0] cv = [-self.right_shoulder_length, 0.0, 0.0] - cev = vector.rotateVectorAroundVector(cv, kv, -self.left_arm_angle) + cev = vector.rotateVectorAroundVector(cv, kv, -self.right_arm_angle) ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) - x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius)], [1, 1]) - x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) - d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.left_arm_radius/self._elementsCount[1])]*2 - d1_shoulder_end_curve1 = [[-0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius)], [1, 1]) + x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) + d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0]]*2 bc = EllipseCurves([[-0.75, 0.0, self.shoulder_height], [-0.75, 1.0, self.shoulder_height]], [[-0.0, 1 / self._elementsCount[0], 0.0]]*2, From 2630f1f586ff8763acfb6f4f00047340be7ad339 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 2 May 2022 10:14:56 +1200 Subject: [PATCH 19/38] Fix nodes derivatives where different mapping is used for adjacent elements. --- src/scaffoldmaker/utils/bifurcation3d2.py | 115 +++++++++++++++------- 1 file changed, 78 insertions(+), 37 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 7cf6ceea..9da9c443 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -954,7 +954,10 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e1 == e1b: remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) else: remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) @@ -982,7 +985,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) @@ -1013,17 +1016,25 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: nids[0] = part_structure.nodeId[e3][e2a][e1b] nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + if e3 == 0: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + if e3 == 0: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, @@ -1038,12 +1049,16 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif setEftScaleFactorIds(eft1, [1], []) scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) elif e2 == e2y: @@ -1051,10 +1066,20 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) @@ -1064,8 +1089,12 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) if e2 == e2y: eft1 = tricubichermite.createEftNoCrossDerivatives() @@ -1140,16 +1169,19 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # if e3 != 2: # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) if part_structure._shoulder_left: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) else: if part_structure._shoulder: if e3 == 0: remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) else: @@ -1159,10 +1191,13 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) else: if part_structure._shoulder_left: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) else: remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, @@ -1184,7 +1219,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e1 == e1b: remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) if part_structure._shoulder: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) else: remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) @@ -1218,8 +1254,10 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if part_structure._shoulder_left: if e3 == 0: remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) else: tripleN = [5, 7] @@ -1234,16 +1272,17 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: - setEftScaleFactorIds(eft1, [1], []) nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.nodeId[e3+1][e2a][e1z] setEftScaleFactorIds(eft1, [1], []) scalefactors = [ -1.0 ] if part_structure._shoulder_left: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) else: remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) @@ -1266,23 +1305,25 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() if part_structure._shoulder_left: - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) if part_structure._shoulder: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) if e2 == e2y: if part_structure._shoulder: eft1 = tricubichermite.createEftNoCrossDerivatives() - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) elif e1 == e1y: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() if part_structure._shoulder_left: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) else: if e1 < e1a: From 95c4f2ec931e83efd561ed9a22114da7c9e106fa Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 5 May 2022 01:05:41 +1200 Subject: [PATCH 20/38] Change middle box and fix derivatives --- src/scaffoldmaker/utils/bifurcation3d2.py | 680 +++++++++++++++++++--- src/scaffoldmaker/utils/cylindermesh.py | 4 +- 2 files changed, 607 insertions(+), 77 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 9da9c443..1c9f09a8 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -246,11 +246,13 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): mesh = self._mesh base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() - torso_upper_part = BaseLeg(self._elementsCount, base_c) + elementsCount = [4,4,2] + torso_upper_part = BaseLeg(elementsCount, base_c) self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) self._torso_upper_part = torso_upper_part +<<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD shoulder_part = BaseLeg(self._elementsCount, nodeparams2) @@ -260,6 +262,9 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): ======= shoulder_part = BaseLeg(self._elementsCount, shoulder_lc, shoulder_right=True) >>>>>>> 9619665 (Modify axes and clean the code and make some classes) +======= + shoulder_part = BaseLeg(elementsCount, shoulder_lc, shoulder_right=True) +>>>>>>> c6c23f0 (Change middle box and fix derivatives) shoulder_part._shoulder = True self.remove_duplicate_nodes_from_shoulder(shoulder_part) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) @@ -267,12 +272,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) self._shoulder_part = shoulder_part - joining_box = JoiningBox([1, 4, 1], self.shoulder_height) - self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - self.join_box_to_bottom_and_shoulder(joining_box, torso_upper_part, shoulder_part) - self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - shoulder_part_left = BaseLeg(self._elementsCount, shoulder_rc, shoulder_left=True) + shoulder_part_left = BaseLeg(elementsCount, shoulder_rc, shoulder_left=True) shoulder_part_left._shoulder_left = True self.remove_duplicate_nodes_from_shoulder(shoulder_part_left, 1) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) @@ -280,7 +280,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) self._shoulder_part_left = shoulder_part_left - neck_part = BaseLeg(self._elementsCount, neck_c) + neck_part = BaseLeg(elementsCount, neck_c) neck_part._neck = True self.remove_duplicate_nodes_from_neck(neck_part) self.generateNodes(nodes, fieldmodule, coordinates, neck_part) @@ -288,14 +288,27 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, neck_part) self._neck_part = neck_part - joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) - self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) + box_part = BoxPart(elementsCount, torso_upper_part, shoulder_part, shoulder_part_left, neck_part) + self.generateNodes(nodes, fieldmodule, coordinates, box_part) + self.generateElements(mesh, fieldmodule, coordinates, box_part) + + - joining_box_3 = JoiningBox3([1, 4, 1], joining_box, neck_part) - self.generateElements(mesh, fieldmodule, coordinates, joining_box_3) - joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) - self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) + + # joining_box = JoiningBox([1, elementsCount[1], elementsCount[2]//2], self.shoulder_height) + # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) + # self.join_box_to_bottom_and_shoulder(joining_box, torso_upper_part, shoulder_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box) + + # joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) + # + # joining_box_3 = JoiningBox3([1, 4, 1], joining_box, neck_part) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box_3) + # + # joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) + # self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) def create_branch_cylinder(self, radius, length, number_of_elements, path_list=None, part1=None, attach_bottom=True, branch_type=BranchType.LEFT_ARM): @@ -344,15 +357,16 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): armpit = self.armpit + elementsCountQuarter = [3,3,2] bc = EllipseCurves([[0.0, 0.0, 0.0], [self.torso_radius, 0.0, 0.0]], - [[self.torso_radius / self._elementsCount[0], 0.0, 0.0]]*2, + [[self.torso_radius / elementsCountQuarter[0], 0.0, 0.0]]*2, [[0.0, 0.0, 0.0], [0.0, self.torso_radius, 0.0]], - [[0.0, 1/self._elementsCount[1], 0.0]]*2) + [[0.0, 1/elementsCountQuarter[1], 0.0]]*2) tc = EllipseCurves([[0.0, 0.0, 1.4], armpit], - [[1 / self._elementsCount[0], 0.0, 0.0], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[1 / elementsCountQuarter[0], 0.0, 0.0], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], [[0.0, 0.0, 1.4], [0.0, 1.0, 1.4]], - [[0.0, 1 / self._elementsCount[1], 0.0]]*2) + [[0.0, 1 / elementsCountQuarter[1], 0.0]]*2) base_c = CylinderCurves(bc, tc) @@ -560,11 +574,11 @@ def condition(n2, n1): def index(n2, n1): if c: if n2 == 0 and n1 == 1: - return n1 - 1, 4 - n2 - 1 - if n2 == 0 and n1 == 3: - return n1 + 1, 4 - n2 - 1 + return n1 - 1, shoulder_part._elementsCount[0] - n2 - 1 + if n2 == 0 and n1 == shoulder_part._elementsCount[0] - 1: + return n1 + 1, shoulder_part._elementsCount[0] - n2 - 1 else: - return n1, 4 - n2 + return n1, shoulder_part._elementsCount[0] - n2 else: return n2, n1 @@ -613,7 +627,7 @@ def remove_duplicate_nodes_from_neck(self, neck_part): """ for n2 in range(neck_part._elementsCount[1] + 1): for n1 in range(neck_part._elementsCount[0] + 1): - if n1 != 2: + if n1 <= 1 or n1 >= neck_part._elementsCount[0] - 1: neck_part.px[0][n2][n1] = None neck_part.pd1[0][n2][n1] = None neck_part.pd2[0][n2][n1] = None @@ -629,19 +643,19 @@ def join_neck_to_torso(self, neck_part, shoulder_part, shoulder_part_left): for n2 in range(neck_part._elementsCount[1] + 1): for n1 in range(neck_part._elementsCount[0] + 1): if n1 < 2: - n1s = 4 - n1 + n1s = neck_part._elementsCount[0] - n1 neck_part.nodeId[0][n2][n1] = shoulder_part.nodeId[0][n2][n1s] neck_part.px[0][n2][n1] = shoulder_part.px[0][n2][n1s] neck_part.pd1[0][n2][n1] = shoulder_part.pd1[0][n2][n1s] neck_part.pd2[0][n2][n1] = shoulder_part.pd2[0][n2][n1s] neck_part.pd3[0][n2][n1] = shoulder_part.pd3[0][n2][n1s] - elif n1 > 2: - if n2 == 0 or n2 == 4: - if n1 == 3: + elif n1 >= neck_part._elementsCount[0] - 1: + if n2 == 0 or n2 == neck_part._elementsCount[1]: + if n1 == neck_part._elementsCount[0] - 1: n2s = n1+1 if n2 == 0: n1s = n2 + 1 - if n2 == 4: + if n2 == neck_part._elementsCount[1]: n1s = n2 - 1 else: n2s = n1 @@ -752,12 +766,401 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] - if isinstance(part_structure, JoiningBox): + if isinstance(part_structure, BoxPart): + if e3 == 0 and e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == 0: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == part_structure._elementsCount[1]: + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + + if e2 == e2a or e2 == e2z: + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e3 == 0 and e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + + else: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e3 == part_structure._elementsCount[2] - 1 and e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [1])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e3 == part_structure._elementsCount[2] - 1 and e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + # if e2 == e2a: + # if e3 == 0 and e1 == 0: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # elif e3 == 0 and e1 == e1z: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + # elif e3 == part_structure._elementsCount[2] and e1 == 0: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # elif e3 == part_structure._elementsCount[2] and e1 == e1z: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # elif e2 == e2z: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # else: + # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + + + elif isinstance(part_structure, JoiningBox): eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == 0: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == part_structure._elementsCount[1]: + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + if e2 == e2a or e2 == e2z: if e2 == e2a: remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) @@ -783,18 +1186,20 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) else: remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) elif isinstance(part_structure, JoiningBoxRight): eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) @@ -807,10 +1212,12 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) @@ -826,10 +1233,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - elif isinstance(part_structure, JoiningBox3): eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -845,14 +1248,16 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1, 3, 5, 6], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) @@ -863,23 +1268,23 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [1, 2, 5, 6], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2, 5, 6], Node.VALUE_LABEL_D_DS2, + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) elif isinstance(part_structure, JoiningBox4): eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] if e2 == e2a: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) @@ -894,8 +1299,10 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) @@ -909,8 +1316,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) else: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) @@ -1154,6 +1559,9 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e3 == 0 and e1 == e1b: remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, @@ -1212,12 +1620,15 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) else: remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) if (e1 == e1b) or (e1 == e1y): # map top triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if e3 == 0: + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) if part_structure._shoulder: if e3 == 0: remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) @@ -1269,6 +1680,9 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) 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] ) ]) + if e3 == 0: + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: @@ -1310,13 +1724,23 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) if part_structure._shoulder: if e3 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if e2 == e2y: if part_structure._shoulder: eft1 = tricubichermite.createEftNoCrossDerivatives() if e3 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + elif e1 == e1y: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() @@ -1336,6 +1760,20 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif scalefactors = [ -1.0 ] 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])]) + if e3 == 0 and part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and part_structure._shoulder: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if not all(nids): continue @@ -1380,7 +1818,7 @@ def __init__(self, elementsCount, cyl_curves, shoulder_right=False, shoulder_lef :param mesh: :param nodes: """ - elementsCount = [4, 4, 2] + # elementsCount = [4, 4, 2] self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] self._shoulder = False self._shoulder_left = False @@ -1670,10 +2108,20 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): n1, n2 = shield.convertRimIndex(n) ellipse.pd1[n2][n1] = td1[n] + # for n in range(elementsCountAround + 1, 2*elementsCountAround+1): + # n1, n2 = shield.convertRimIndex(n) + # n1q1, n2q1 = shield.convertRimIndex(2*elementsCountAround - n) + # ellipse.px[n2][n1] = [-ellipse.px[n2q1][n1q1][0], ellipse.px[n2q1][n1q1][1], ellipse.px[n2q1][n1q1][2]] + # ellipse.pd1[n2][n1] = [ellipse.pd1[n2q1][n1q1][0], -ellipse.pd1[n2q1][n1q1][1], -ellipse.pd1[n2q1][n1q1][2]] + # ellipse.pd2[n2][n1] = [ellipse.pd2[n2q1][n1q1][0], ellipse.pd2[n2q1][n1q1][1], ellipse.pd2[n2q1][n1q1][2]] + # ellipse.pd3[n2][n1] = [-ellipse.pd3[n2q1][n1q1][0], ellipse.pd3[n2q1][n1q1][1], ellipse.pd3[n2q1][n1q1][2]] + # recalculate the inner nodes. ellipse.setRimNodes() rscx, rscd1, rscd2, rscd3 = ellipse.createMirrorCurve() - ellipse.createRegularRowCurves(ellipse.px[:self._elementsCount[1]+1][self._elementsCount[0]], rscd1, rscd3) + rscx2 = [ellipse.px[c][self._elementsCount[0]] for c in range(self._elementsCount[1]+1)] + ellipse.createRegularRowCurves(rscx2, rscd1, rscd3) + # ellipse.createRegularRowCurves(ellipse.px[:self._elementsCount[1]+1][self._elementsCount[0]], rscd1, rscd3) ellipse.createRegularColumnCurves() shield.getTriplePoints(0) ellipse.smoothTriplePointsCurves() @@ -1716,22 +2164,45 @@ def __init__(self, elementsCount, height): self._elementsCount = elementsCount self._joining_box = True - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + elementsCountAlong = elementsCount[1]//2-1 # It should be consistent with the number of elements for shoulders. + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCountAlong)] + + radius = 1.0 + base_height = 1.4 + + # nx = [[0.0, radius, base_height+1*(height - base_height)/elementsCount[2]], [0.0, 0.0, base_height+1*(height - base_height)/elementsCount[2]]] + # nx.append([nx[0][0], -nx[0][1], nx[0][2]]) + # nd1 = [[0.0, -2 * radius / elementsCount[1], 0.0]] * 3 + elementsCountOut = elementsCount[1] + + n3 = 1 + centre = [(elementsCountAlong-n3)*(height - base_height)/elementsCountAlong, 0.0, base_height+n3*(height - base_height)/elementsCountAlong] + ve = [0.0, radius, 0.0] + nx = [vector.addVectors([centre, ve], [1, 1]), centre, vector.addVectors([centre, ve], [1, -1])] + nd1 = [vector.scaleVector(ve, -2*vector.magnitude(ve)/elementsCount[1])]*3 + + tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) - self.px[1][0][1] = [0.0, 1.0, height] - self.px[1][1][1] = [0.0, 0.5, height] - self.px[1][2][1] = [0.0, 0.0, height] - self.px[1][3][1] = [0.0, -0.5, height] - self.px[1][4][1] = [0.0, -1.0, height] for n2 in range(elementsCount[1]+1): - self.pd1[1][n2][1] = [0.0, -0.5, 0.0] - self.pd2[1][n2][1] = [0.5, 0.0, 0.0] - self.pd3[1][n2][1] = [0.0, 0.0, 0.7] + self.px[1][n2][1] = tx[n2] + if n2 == 0: + self.pd1[1][n2][1] = [-0.5, 0.0, 0.0] + self.pd2[1][n2][1] = [0.0, 0.0, 0.7] + self.pd3[1][n2][1] = [-c for c in td1[n2]] + elif n2 == elementsCount[1]: + self.pd1[1][n2][1] = [0.5, 0.0, 0.0] + self.pd2[1][n2][1] = [0.0, 0.0, 0.7] + self.pd3[1][n2][1] = td1[n2] + else: + self.pd1[1][n2][1] = td1[n2] + self.pd2[1][n2][1] = [0.0, 0.0, 0.7] + self.pd3[1][n2][1] = [-0.5, 0.0, 0.0] class CylinderConnectingToBox: @@ -1931,6 +2402,65 @@ def __init__(self, elementsCount, joining_box_3, neck_part, joining_box_right): self.pd3[1][n2][1] = neck_part.pd3[0][n2][3] +class BoxPart(): + def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): + self._elementsCount = [2, 4, 2] + self._joining_box = True + elementsCount = [2, 4, 2] + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + torso_elements_count = [len(torso.px[0][0])-1, len(torso.px[0])-1, len(torso.px)-1] + n3 = 1 + p = [self.nodeId, self._px, self.pd1, self.pd2, self.pd3] + p1 = [torso.nodeId, torso.px, torso.pd1, torso.pd2, torso.pd3] + p2 = [neck.nodeId, neck.px, neck.pd1, neck.pd2, neck.pd3] + p3 = [shoulder_left.nodeId, shoulder_left.px, shoulder_left.pd1, shoulder_left.pd2, shoulder_left.pd3] + p4 = [shoulder_right.nodeId, shoulder_right.px, shoulder_right.pd1, shoulder_right.pd2, shoulder_right.pd3] + + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if (n2 == 0 or n2 == elementsCount[1]) and n1 == 0: + n2p, n1p = n2, n1 + 1 + elif (n2 == 0 or n2 == elementsCount[1]) and n1 == torso_elements_count[0] - 2: + n2p, n1p = n2, n1 + 1 + else: + n2p, n1p = n2, n1 + 1 + + if n3 == 0: + p[i][n3][n2][n1] = p1[i][torso_elements_count[2]][n2p][n1p] + elif n3 == torso_elements_count[2]: + p[i][elementsCount[2]][n2][n1] = p2[i][0][n2p][n1p] + else: + if n1 == 0: + p[i][n3][n2][0] = p3[i][0][n2][torso_elements_count[1]//2] + elif n1 == elementsCount[0]: + p[i][n3][n2][elementsCount[0]] = p4[i][0][torso_elements_count[1]//2][n2] + elementsCountOut = elementsCount[2] + for n2 in range(elementsCount[1] + 1): + for n1 in range(1, elementsCount[0]): + nx = [self._px[0][n2][n1], self._px[elementsCount[2]][n2][n1]] + nd1 = [self.pd2[0][n2][n1], self.pd2[elementsCount[2]][n2][n1]] + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) + td1 = interpolateSampleCubicHermite( + [self.pd1[0][n2][n1], self.pd1[elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [self.pd3[0][n2][n1], self.pd3[elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + for n3 in range(1, elementsCount[2]): + self.px[n3][n2][n1] = tx[n3] + self._px[n3][n2][n1] = tx[n3] + self.pd1[n3][n2][n1] = td1[n3] + self.pd2[n3][n2][n1] = td2[n3] + self.pd3[n3][n2][n1] = td3[n3] diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index 100be098..82eaeac9 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -598,8 +598,8 @@ def createRegularRowCurves(self, rscx, rscd1, rscd3): for n2 in range(n2d, n2m + 1): txm, td3m, pe, pxi, psf = sampleCubicHermiteCurves( [btx[n2][n1a], rscx[n2 - n2a], btx[n2][n1z]], - [vector.setMagnitude(btd3[n2][n1a], -1.0), rscd3[n2 - n2a], btd3[n2][n1z]], - self.elementsCountAcrossMinor-2*self.elementsCountAcrossShell, arcLengthDerivatives=True) + [vector.scaleVector(btd3[n2][n1a], -1.0), rscd3[n2 - n2a], btd3[n2][n1z]], + self.elementsCountAcrossMinor-2*self.elementsCountAcrossShell) td1m = interpolateSampleCubicHermite([[-btd1[n2][n1a][c] for c in range(3)], rscd1[n2 - n2a], btd1[n2][n1z]], [[0.0, 0.0, 0.0]] * 3, pe, pxi, psf)[0] From 47fb57d527c09224208f52f15373c2a7d5feb58c Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Wed, 11 May 2022 13:46:41 +1200 Subject: [PATCH 21/38] Fix increasing number of elements issue --- .../meshtype_3d_solidbifurcation2.py | 14 +- src/scaffoldmaker/utils/bifurcation3d2.py | 738 +++++++++++------- 2 files changed, 473 insertions(+), 279 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 977df439..930c2335 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -292,20 +292,20 @@ def generateBaseMesh(region, options): bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, - right_shoulder_length, armpit) + right_shoulder_length, armpit, [elementsCountAcrossMajor, elementsCountAcrossMajor, 2]) bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], - right_arm_length, [4, 4, rightArmNumberOfElements], + right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], branch_type=BranchType.LEFT_ARM) bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], - right_arm_length, [4, 4, rightArmNumberOfElements], + right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], branch_type=BranchType.RIGHT_ARM) neck_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2]*2, [neck_radius2]*2], neck_length, - [4,4, neck_number_of_elements], branch_type=BranchType.NECK) + [elementsCountAcrossMajor,elementsCountAcrossMajor, neck_number_of_elements], branch_type=BranchType.NECK) neck_cyliner_shield = neck_cylinder._shield pn = PathNodes(neck_cyliner_shield, [[neck_radius2]*2, [head_radius, neck_radius2]], - head_length/head_number_of_elements, [4,4, 1]) + head_length/head_number_of_elements, [elementsCountAcrossMajor,elementsCountAcrossMajor, 1]) path_list = pn.get_path_list() path_list[1][0] = vector.addVectors( [path_list[1][0], vector.setMagnitude([0.0, -1.0, 0.0], @@ -322,7 +322,7 @@ def generateBaseMesh(region, options): head_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], head_length/head_number_of_elements, - [4,4, head_number_of_elements], path_list=path_list, + [elementsCountAcrossMajor,elementsCountAcrossMajor, head_number_of_elements], path_list=path_list, part1=neck_cyliner_shield, branch_type=4) cap = bifurcation1.create_branch_cap(head_cylinder, head_radius) @@ -330,7 +330,7 @@ def generateBaseMesh(region, options): lower_torso_cylinder = bifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], lower_torso_length, - [4,4, lower_torso_number_of_elements], + [elementsCountAcrossMajor,elementsCountAcrossMajor, lower_torso_number_of_elements], part1=bifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 1c9f09a8..b049ba4c 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -194,7 +194,7 @@ class BifurcationMesh: """ def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, - shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit): + shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit, elements_count): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -202,6 +202,7 @@ def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radi # generate the mesh elementsCount = [2, 2, 5] self._elementsCount = elementsCount + self._elements_count = elements_count self._region = region self.torso_radius = torso_radius @@ -246,7 +247,8 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): mesh = self._mesh base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() - elementsCount = [4,4,2] + elementsCount = self._elements_count + # elementsCount = [6,6,2] torso_upper_part = BaseLeg(elementsCount, base_c) self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) @@ -288,7 +290,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, neck_part) self._neck_part = neck_part - box_part = BoxPart(elementsCount, torso_upper_part, shoulder_part, shoulder_part_left, neck_part) + box_part = BoxPart([elementsCount[0] - 2, elementsCount[1], elementsCount[0] - 2], torso_upper_part, shoulder_part, shoulder_part_left, neck_part) self.generateNodes(nodes, fieldmodule, coordinates, box_part) self.generateElements(mesh, fieldmodule, coordinates, box_part) @@ -767,308 +769,413 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] if isinstance(part_structure, BoxPart): - if e3 == 0 and e1 == 0: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == 0: - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == part_structure._elementsCount[1]: - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) + if e3 == 0: + if e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == 0: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == part_structure._elementsCount[1]: + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) - if e2 == e2a or e2 == e2z: + if e2 == e2a or e2 == e2z: + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + + else: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + elif e3 == part_structure._elementsCount[2] - 1: + if e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [1])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1]), - (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - elif e3 == 0 and e1 == e1z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2a: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1]), - (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) - elif e2 == e2z: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - else: - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) - elif e3 == part_structure._elementsCount[2] - 1 and e1 == 0: + else: eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == e2a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1]), - (Node.VALUE_LABEL_D_DS2, [1])]) - - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, []), - (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) + if e1 == 0: + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + else: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - elif e3 == part_structure._elementsCount[2] - 1 and e1 == e1z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2a: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1]), - (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, [1]), - (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [])]) - elif e2 == e2z: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - else: - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, - [(Node.VALUE_LABEL_D_DS2, [])]) # if e2 == e2a: # if e3 == 0 and e1 == 0: # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) @@ -1347,6 +1454,14 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1]), (Node.VALUE_LABEL_D_DS1, [])]) + elif e1b < e1 < e1y: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + else: remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) @@ -1354,7 +1469,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) - if (e1 == e1b) or (e1 == e1y): + # if (e1 == e1b) or (e1 == e1y): + if e1 == e1b: # map bottom triple point element if e1 == e1b: remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) @@ -1404,6 +1520,11 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + elif e1b < e1 < e1y: + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): if e1 == e1a: @@ -1524,6 +1645,60 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + elif e2b < e2 < e2y: + if e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS1, []), + # (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + + # else: + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + + else: if e1 < e1a: nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], @@ -1571,6 +1746,11 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if e3 == 0: + if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) if (e1 == e1b) or (e1 == e1y): # map bottom triple point element if e1 == e1b: @@ -1746,9 +1926,20 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif eft1 = tricubichermite.createEftNoCrossDerivatives() if part_structure._shoulder_left: if e3 == 0: + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + else: + if part_structure._shoulder_left: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and e2 <= e2b: + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + + + else: if e1 < e1a: nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], @@ -2402,12 +2593,16 @@ def __init__(self, elementsCount, joining_box_3, neck_part, joining_box_right): self.pd3[1][n2][1] = neck_part.pd3[0][n2][3] -class BoxPart(): +class BoxPart: def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): - self._elementsCount = [2, 4, 2] + # self._elementsCount = [2, 4, 2] + # self._elementsCount = [4, 6, 4] + self._elementsCount = elementsCount self._joining_box = True - elementsCount = [2, 4, 2] + # elementsCount = [2, 4, 2] + # elementsCount = [4, 6, 4] + elementsCount = elementsCount self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] @@ -2418,7 +2613,6 @@ def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] torso_elements_count = [len(torso.px[0][0])-1, len(torso.px[0])-1, len(torso.px)-1] - n3 = 1 p = [self.nodeId, self._px, self.pd1, self.pd2, self.pd3] p1 = [torso.nodeId, torso.px, torso.pd1, torso.pd2, torso.pd3] p2 = [neck.nodeId, neck.px, neck.pd1, neck.pd2, neck.pd3] @@ -2438,13 +2632,13 @@ def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): if n3 == 0: p[i][n3][n2][n1] = p1[i][torso_elements_count[2]][n2p][n1p] - elif n3 == torso_elements_count[2]: + elif n3 == elementsCount[2]: p[i][elementsCount[2]][n2][n1] = p2[i][0][n2p][n1p] else: if n1 == 0: - p[i][n3][n2][0] = p3[i][0][n2][torso_elements_count[1]//2] + p[i][n3][n2][0] = p3[i][0][n2][n3+1] elif n1 == elementsCount[0]: - p[i][n3][n2][elementsCount[0]] = p4[i][0][torso_elements_count[1]//2][n2] + p[i][n3][n2][elementsCount[0]] = p4[i][0][n3+1][n2] elementsCountOut = elementsCount[2] for n2 in range(elementsCount[1] + 1): From 2cb432234a4e7d08e8eccc41c57ebc6c0327d15f Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Wed, 11 May 2022 15:07:29 +1200 Subject: [PATCH 22/38] change the order of options --- .../meshtype_3d_solidbifurcation2.py | 120 ++++++------------ 1 file changed, 41 insertions(+), 79 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 930c2335..3f70a629 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -1,6 +1,6 @@ """ -Generates a solid cylinder using a ShieldMesh of all cube elements, - with variable numbers of elements in major, minor, shell and axial directions. +Generates a whole body scaffold using a mesh of all cube elements, + with features to control arms, torso, neck and head. """ from __future__ import division @@ -19,8 +19,8 @@ class MeshType_3d_solidbifurcation2(Scaffold_base): """ -Generates a solid cylinder using a ShieldMesh of all cube elements, -with variable numbers of elements in major, minor, shell and axial directions. +Generates a whole body scaffold using a mesh of all cube elements, + with features to control arms, torso, neck and head. """ centralPathDefaultScaffoldPackages = { # 'Cylinder 1': ScaffoldPackage(MeshType_1d_path1, { @@ -64,46 +64,48 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Central path': copy.deepcopy(centralPathOption), 'Central path1': copy.deepcopy(centralPathOption1), 'Armpit': [1.2, 0.0, 1.0], - 'Torso radius': 1.0, - 'Left arm radius': 1.0, - 'Right arm radius': 1.0, - 'Neck radius': 0.8, - 'Neck radius 2': 0.8, - 'Neck length': 0.4, - 'Neck number of elements': 2, - 'Neck shoulder point': [0.7, 0.0, 2.8], 'Head length': 1.0, 'Head number of elements': 5, 'Head radius': 1.0, - 'Shoulder height': 2.2, - 'Shoulder joint': [1.1, 0.0, 2.4], - 'Shoulder point': [1.0, 0.0, 2.8], - 'Shoulder start': [0.5, 0.0, 2.2], + 'Left arm radius': 1.0, + 'Lower torso length': 5.5, + 'Lower torso number of elements': 4, + 'Lower torso radii': [1.3, 1.0], 'Neck height': 3.6, +<<<<<<< HEAD 'Right arm angle': 0.0, <<<<<<< HEAD 'Right arm length': 1.7, ======= 'Left arm angle': 0.0, 'Right shoulder length': 0.95, +======= + 'Neck length': 0.4, + 'Neck number of elements': 2, + 'Neck radius': 0.8, + 'Neck radius 2': 0.8, +>>>>>>> 5bc5787 (change the order of options) 'Right arm length': 2.0, 'Right arm number of elements': 5, + 'Right arm radius': 1.0, + 'Right shoulder length': 0.95, 'Right wrist radius': 0.8, +<<<<<<< HEAD 'Lower torso length': 5.5, 'Lower torso number of elements': 4, 'Lower torso radii': [1.3, 1.0], >>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) +======= + 'Shoulder height': 2.2, + 'Torso radius': 1.0, +>>>>>>> 5bc5787 (change the order of options) 'Number of elements across major': 4, - 'Number of elements across minor': 4, 'Number of elements across shell': 0, 'Number of elements across transition': 1, - 'Number of elements along': 1, 'Shell element thickness proportion': 1.0, - 'Lower half': False, 'Use cross derivatives': False, 'Refine': False, 'Refine number of elements across major': 1, - 'Refine number of elements along': 1 } return options @@ -113,42 +115,32 @@ def getOrderedOptionNames(): 'Central path', 'Central path1', 'Armpit', - 'Torso radius', - 'Left arm radius', - 'Right arm radius', - 'Neck radius', - 'Neck radius 2', - 'Neck length', - 'Neck number of elements', - 'Neck shoulder point', 'Head length', 'Head number of elements', 'Head radius', - 'Shoulder joint', - 'Shoulder height', - 'Shoulder point', - 'Shoulder start', + 'Left arm radius', + 'Lower torso length', + 'Lower torso number of elements', + 'Lower torso radii', 'Neck height', - 'Right arm angle', - 'Left arm angle', - 'Right shoulder length', + 'Neck length', + 'Neck number of elements', + 'Neck radius', + 'Neck radius 2', 'Right arm length', 'Right arm number of elements', + 'Right arm radius', + 'Right shoulder length', 'Right wrist radius', - 'Lower torso length', - 'Lower torso number of elements', - 'Lower torso radii', + 'Shoulder height', + 'Torso radius', 'Number of elements across major', - 'Number of elements across minor', 'Number of elements across shell', 'Number of elements across transition', - 'Number of elements along', 'Shell element thickness proportion', - 'Lower half', 'Refine', 'Refine number of elements across major', - 'Refine number of elements along' - ] + ] @classmethod def getOptionValidScaffoldTypes(cls, optionName): @@ -192,15 +184,9 @@ def checkOptions(cls, options): if options['Number of elements across major'] % 2: options['Number of elements across major'] += 1 - if options['Number of elements across minor'] < 4: - options['Number of elements across minor'] = 4 - if options['Number of elements across minor'] % 2: - options['Number of elements across minor'] += 1 - if options['Number of elements along'] < 1: - options['Number of elements along'] = 1 if options['Number of elements across transition'] < 1: options['Number of elements across transition'] = 1 - Rcrit = min(options['Number of elements across major']-4, options['Number of elements across minor']-4)//2 + Rcrit = min(options['Number of elements across major']-4, options['Number of elements across major']-4)//2 if options['Number of elements across shell'] + options['Number of elements across transition'] - 1 > Rcrit: dependentChanges = True options['Number of elements across shell'] = Rcrit @@ -221,32 +207,12 @@ 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'] - elementsCountAlong = options['Number of elements along'] shellProportion = options['Shell element thickness proportion'] useCrossDerivatives = options['Use cross derivatives'] - fm = region.getFieldmodule() - coordinates = findOrCreateFieldCoordinates(fm) - - # cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) - # - # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF - # - # base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, - # elementsCountAcrossTransition, - # shellProportion, - # [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - # cylinderCentralPath.minorRadii[0]) - # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, - # cylinderShape=cylinderShape, - # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) torso_radius = options['Torso radius'] left_arm_radius = options['Left arm radius'] right_arm_radius = options['Right arm radius'] @@ -256,17 +222,11 @@ def generateBaseMesh(region, options): neck_number_of_elements = options['Neck number of elements'] shoulder_height = options['Shoulder height'] neck_height = options['Neck height'] - right_arm_angle = options['Right arm angle'] - left_arm_angle = options['Left arm angle'] right_shoulder_length = options['Right shoulder length'] right_arm_length = options['Right arm length'] rightArmNumberOfElements = options['Right arm number of elements'] righ_wrist_radius = options['Right wrist radius'] - shoulder_joint = options['Shoulder joint'] armpit = options['Armpit'] - neck_shoulder = options['Neck shoulder point'] - shoulder_point = options['Shoulder point'] - shoulder_start = options['Shoulder start'] head_length = options['Head length'] head_number_of_elements = options['Head number of elements'] head_radius = options['Head radius'] @@ -274,7 +234,8 @@ def generateBaseMesh(region, options): lower_torso_number_of_elements = options['Lower torso number of elements'] lower_torso_radii = options['Lower torso radii'] - + fm = region.getFieldmodule() + coordinates = findOrCreateFieldCoordinates(fm) tmpRegion = region.createRegion() centralPath.generate(tmpRegion) @@ -326,7 +287,6 @@ def generateBaseMesh(region, options): part1=neck_cyliner_shield, branch_type=4) cap = bifurcation1.create_branch_cap(head_cylinder, head_radius) - bifurcation1.smooth_all_derivatives() lower_torso_cylinder = bifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], lower_torso_length, @@ -334,6 +294,8 @@ def generateBaseMesh(region, options): part1=bifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) + bifurcation1.smooth_all_derivatives() + annotationGroup = [] return annotationGroup @@ -346,5 +308,5 @@ def refineMesh(cls, meshRefinement, options): """ assert isinstance(meshRefinement, MeshRefinement) refineElementsCountAcrossMajor = options['Refine number of elements across major'] - refineElementsCountAlong = options['Refine number of elements along'] + refineElementsCountAlong = options['Refine number of elements across major'] meshRefinement.refineAllElementsCubeStandard3d(refineElementsCountAcrossMajor, refineElementsCountAlong, refineElementsCountAcrossMajor) From bfc2d2147f73c21a9ecd233bf03f2b8a05f1858e Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 17 May 2022 18:31:26 +1200 Subject: [PATCH 23/38] Fix sphere bad element --- .../meshtype_3d_solidbifurcation2.py | 2 +- src/scaffoldmaker/utils/bifurcation3d2.py | 20 +------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 3f70a629..4f1ffe94 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -294,7 +294,7 @@ def generateBaseMesh(region, options): part1=bifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) - bifurcation1.smooth_all_derivatives() + # bifurcation1.smooth_all_derivatives() annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index b049ba4c..a9b89ef8 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -157,7 +157,7 @@ def __init__(self, fieldmodule, coordinates, mesh, nodes, part1, radius): n1c = 1 elif n2 < 1 and n1 == elementsCountAcross[1] - n2: n1c = elementsCountAcross[1] - 1 - elif n2 > 3: + elif n2 > elementsCountAcross[1] - 1: if n1 == elementsCountAcross[1] - n2: n1c = 1 elif n1 == n2: @@ -294,24 +294,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateNodes(nodes, fieldmodule, coordinates, box_part) self.generateElements(mesh, fieldmodule, coordinates, box_part) - - - - - # joining_box = JoiningBox([1, elementsCount[1], elementsCount[2]//2], self.shoulder_height) - # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - # self.join_box_to_bottom_and_shoulder(joining_box, torso_upper_part, shoulder_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - # joining_box_right = JoiningBoxRight([1, 4, 1], torso_upper_part, shoulder_part_left, joining_box) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box_right) - # - # joining_box_3 = JoiningBox3([1, 4, 1], joining_box, neck_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box_3) - # - # joining_box_4 = JoiningBox4([1, 4, 1], joining_box_3, neck_part, joining_box_right) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box_4) - def create_branch_cylinder(self, radius, length, number_of_elements, path_list=None, part1=None, attach_bottom=True, branch_type=BranchType.LEFT_ARM): if branch_type == BranchType.LEFT_ARM: From d2a67afc17186b6fee5ffda7ed1d6fa47f17a0ce Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 17 May 2022 18:38:16 +1200 Subject: [PATCH 24/38] Rename bifurcation to trifurcation --- .../meshtype_3d_solidbifurcation2.py | 20 ++++++++-------- src/scaffoldmaker/utils/bifurcation3d2.py | 24 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 4f1ffe94..ff2f2923 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -13,7 +13,7 @@ from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.utils import vector -from scaffoldmaker.utils.bifurcation3d2 import BifurcationMesh, BranchType, PathNodes +from scaffoldmaker.utils.bifurcation3d2 import TrifurcationMesh, BranchType, PathNodes from scaffoldmaker.utils.meshrefinement import MeshRefinement @@ -251,17 +251,17 @@ def generateBaseMesh(region, options): if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: left_arm_angle = -left_arm_angle - bifurcation1 = BifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, + trifurcation1 = TrifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, right_shoulder_length, armpit, [elementsCountAcrossMajor, elementsCountAcrossMajor, 2]) - bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], + trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], branch_type=BranchType.LEFT_ARM) - bifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], + trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], branch_type=BranchType.RIGHT_ARM) - neck_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2]*2, [neck_radius2]*2], neck_length, + neck_cylinder = trifurcation1.create_branch_cylinder([[neck_radius2]*2, [neck_radius2]*2], neck_length, [elementsCountAcrossMajor,elementsCountAcrossMajor, neck_number_of_elements], branch_type=BranchType.NECK) neck_cyliner_shield = neck_cylinder._shield @@ -281,20 +281,20 @@ def generateBaseMesh(region, options): else: path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) - head_cylinder = bifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], + head_cylinder = trifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], head_length/head_number_of_elements, [elementsCountAcrossMajor,elementsCountAcrossMajor, head_number_of_elements], path_list=path_list, part1=neck_cyliner_shield, branch_type=4) - cap = bifurcation1.create_branch_cap(head_cylinder, head_radius) + cap = trifurcation1.create_branch_cap(head_cylinder, head_radius) - lower_torso_cylinder = bifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], + lower_torso_cylinder = trifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], lower_torso_length, [elementsCountAcrossMajor,elementsCountAcrossMajor, lower_torso_number_of_elements], - part1=bifurcation1._torso_upper_part, branch_type=4, + part1=trifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) - # bifurcation1.smooth_all_derivatives() + trifurcation1.smooth_all_derivatives() annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index a9b89ef8..79c40632 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -188,7 +188,7 @@ class BranchType(Enum): LEFT_ARM = 3 -class BifurcationMesh: +class TrifurcationMesh: """ Bifurction mesh generator. """ @@ -226,11 +226,11 @@ def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radi self._shoulder_part_left = None self._neck_part = None - self.createBifurcationMesh3d(fieldmodule, coordinates) + self.createTrifurcationMesh3d(fieldmodule, coordinates) - def createBifurcationMesh3d(self, fieldmodule, coordinates): + def createTrifurcationMesh3d(self, fieldmodule, coordinates): """ - Create a bifurcation. + Create a trifurcation. :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :return: Final values of nextNodeIdentifier, nextElementIdentifier. @@ -578,7 +578,7 @@ def index(n2, n1): shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] - def copyBaseLeg2Bifurcation(self, baseleg, idx): + def copyBaseLeg2Trifurcation(self, baseleg, idx): """ :return: @@ -2112,7 +2112,7 @@ def generate_surface(self, curves, n3): txc1, td1c1 = self.generate1DPath(curves.xc1, curves.d1c1, self._elementsCount[0]) txc2, td1c2 = self.generate1DPath(curves.xc2, curves.d1c2, self._elementsCount[1]) ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, n3) + self.copyEllipseNodesToTrifurcation(ellipse, n3) def generateMiddleLevels(self): """ @@ -2316,9 +2316,9 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): return ellipse - def copyEllipseNodesToBifurcation(self, ellipse, n3): + def copyEllipseNodesToTrifurcation(self, ellipse, n3): """ - Copy ellipse nodes to bifurcation + Copy ellipse nodes to trifurcation :param ellipse: :return: """ @@ -2416,7 +2416,7 @@ def __init__(self, elementsCount): self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] -class BifurcationMeshCrotch: +class TrifurcationMeshCrotch: """ Bifurction mesh generator. """ @@ -2431,11 +2431,11 @@ def __init__(self, fieldModule, coordinates, region): self._elementsCount = elementsCount self._region = region - self.createBifurcationMesh3d(fieldModule, coordinates) + self.createTrifurcationMesh3d(fieldModule, coordinates) - def createBifurcationMesh3d(self, fieldmodule, coordinates): + def createTrifurcationMesh3d(self, fieldmodule, coordinates): """ - Create a bifurcation. + Create a trifurcation. :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :return: Final values of nextNodeIdentifier, nextElementIdentifier. From 84989a9f7d68099a7f29324f92a7f1e9f8285020 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 17 May 2022 18:48:07 +1200 Subject: [PATCH 25/38] Remove unused functions --- src/scaffoldmaker/utils/bifurcation3d2.py | 372 ---------------------- 1 file changed, 372 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 79c40632..35b1971d 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -1238,178 +1238,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # [(Node.VALUE_LABEL_D_DS2, [1])]) # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - elif isinstance(part_structure, JoiningBox): - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == 0: - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == part_structure._elementsCount[1]: - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - - if e2 == e2a or e2 == e2z: - if e2 == e2a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - else: - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - elif isinstance(part_structure, JoiningBoxRight): - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2a: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - elif e2 == e2z: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - - else: - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - - elif isinstance(part_structure, JoiningBox3): - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == e2a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) - - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == e2z: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - else: - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS3, [])]) - - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - elif isinstance(part_structure, JoiningBox4): - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2a: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - elif e2 == e2z: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - else: - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - elif part_structure._neck and e3 == 0: if (e2 < e2b) or (e2 > e2y): if (e1 < e1b) or (e1 > e1y): @@ -2332,90 +2160,6 @@ def copyEllipseNodesToTrifurcation(self, ellipse, n3): self.pd3[n3][n2][n1] = ellipse.pd3[n2e][n1e] -class JoiningBox: - def __init__(self, elementsCount, height): - self._elementsCount = elementsCount - self._joining_box = True - - elementsCountAlong = elementsCount[1]//2-1 # It should be consistent with the number of elements for shoulders. - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCountAlong + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCountAlong)] - - radius = 1.0 - base_height = 1.4 - - # nx = [[0.0, radius, base_height+1*(height - base_height)/elementsCount[2]], [0.0, 0.0, base_height+1*(height - base_height)/elementsCount[2]]] - # nx.append([nx[0][0], -nx[0][1], nx[0][2]]) - # nd1 = [[0.0, -2 * radius / elementsCount[1], 0.0]] * 3 - elementsCountOut = elementsCount[1] - - n3 = 1 - centre = [(elementsCountAlong-n3)*(height - base_height)/elementsCountAlong, 0.0, base_height+n3*(height - base_height)/elementsCountAlong] - ve = [0.0, radius, 0.0] - nx = [vector.addVectors([centre, ve], [1, 1]), centre, vector.addVectors([centre, ve], [1, -1])] - nd1 = [vector.scaleVector(ve, -2*vector.magnitude(ve)/elementsCount[1])]*3 - - tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) - - for n2 in range(elementsCount[1]+1): - self.px[1][n2][1] = tx[n2] - if n2 == 0: - self.pd1[1][n2][1] = [-0.5, 0.0, 0.0] - self.pd2[1][n2][1] = [0.0, 0.0, 0.7] - self.pd3[1][n2][1] = [-c for c in td1[n2]] - elif n2 == elementsCount[1]: - self.pd1[1][n2][1] = [0.5, 0.0, 0.0] - self.pd2[1][n2][1] = [0.0, 0.0, 0.7] - self.pd3[1][n2][1] = td1[n2] - else: - self.pd1[1][n2][1] = td1[n2] - self.pd2[1][n2][1] = [0.0, 0.0, 0.7] - self.pd3[1][n2][1] = [-0.5, 0.0, 0.0] - - -class CylinderConnectingToBox: - """ - - """ - def __init__(self, cylinder_part, idxs, sign): - elementsCount = [cylinder_part._elementsCount[0], cylinder_part._elementsCount[1], 1] - self._elementsCount = elementsCount - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - for n2 in range(elementsCount[1] + 1): - for n1 in range(elementsCount[0]//2 + 1, elementsCount[0] + 1): - if cylinder_part.px[idxs[0]][n2][n1]: - self.px[idxs[0]][n2][n1] = vector.addVectors([cylinder_part.px[idxs[1]][n2][n1], - cylinder_part.pd2[idxs[1]][n2][n1]], [1, sign]) - self.pd1[idxs[0]][n2][n1] = cylinder_part.pd1[idxs[1]][n2][n1] - self.pd2[idxs[0]][n2][n1] = cylinder_part.pd2[idxs[1]][n2][n1] - self.pd3[idxs[0]][n2][n1] = cylinder_part.pd3[idxs[1]][n2][n1] - - -class JoiningTorso: - def __init__(self, elementsCount): - self._elementsCount = elementsCount - self._joining_torso = True - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - class TrifurcationMeshCrotch: """ Bifurction mesh generator. @@ -2459,122 +2203,6 @@ def __init__(self): """ -class JoiningBoxRight: - def __init__(self, elementsCount, bottom_part, shoulder_part_left, joining_box): - self._elementsCount = elementsCount - self._joining_box = True - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - for n2 in range(elementsCount[1]+1): - self.nodeId[1][n2][0] = joining_box.nodeId[1][n2][1] - self.px[1][n2][0] = joining_box.px[1][n2][1] - self.pd1[1][n2][0] = joining_box.pd1[1][n2][1] - self.pd2[1][n2][0] = joining_box.pd2[1][n2][1] - self.pd3[1][n2][0] = joining_box.pd3[1][n2][1] - - self.nodeId[0][n2][0] = joining_box.nodeId[0][n2][1] - self.px[0][n2][0] = joining_box.px[0][n2][1] - self.pd1[0][n2][0] = joining_box.pd1[0][n2][1] - self.pd2[0][n2][0] = joining_box.pd2[0][n2][1] - self.pd3[0][n2][0] = joining_box.pd3[0][n2][1] - - self.nodeId[0][n2][1] = bottom_part.nodeId[2][n2][3] - self.px[0][n2][1] = bottom_part.px[2][n2][3] - self.pd1[0][n2][1] = bottom_part.pd1[2][n2][3] - self.pd2[0][n2][1] = bottom_part.pd2[2][n2][3] - self.pd3[0][n2][1] = bottom_part.pd3[2][n2][3] - - n2s = 2 - n1s = n2 - self.nodeId[1][n2][1] = shoulder_part_left.nodeId[0][n2s][n1s] - self.px[1][n2][1] = shoulder_part_left.px[0][n2s][n1s] - self.pd1[1][n2][1] = shoulder_part_left.pd1[0][n2s][n1s] - self.pd2[1][n2][1] = shoulder_part_left.pd2[0][n2s][n1s] - self.pd3[1][n2][1] = shoulder_part_left.pd3[0][n2s][n1s] - - -class JoiningBox3: - def __init__(self, elementsCount, joining_box, neck_part): - self._elementsCount = elementsCount - self._joining_box = True - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - for n2 in range(elementsCount[1]+1): - self.nodeId[0][n2][0] = joining_box.nodeId[1][n2][0] - self.px[0][n2][0] = joining_box.px[1][n2][0] - self.pd1[0][n2][0] = joining_box.pd1[1][n2][0] - self.pd2[0][n2][0] = joining_box.pd2[1][n2][0] - self.pd3[0][n2][0] = joining_box.pd3[1][n2][0] - self.nodeId[0][n2][1] = joining_box.nodeId[1][n2][1] - self.px[0][n2][1] = joining_box.px[1][n2][1] - self.pd1[0][n2][1] = joining_box.pd1[1][n2][1] - self.pd2[0][n2][1] = joining_box.pd2[1][n2][1] - self.pd3[0][n2][1] = joining_box.pd3[1][n2][1] - - self.nodeId[1][n2][0] = neck_part.nodeId[0][n2][1] - self.px[1][n2][0] = neck_part.px[0][n2][1] - self.pd1[1][n2][0] = neck_part.pd1[0][n2][1] - self.pd2[1][n2][0] = neck_part.pd2[0][n2][1] - self.pd3[1][n2][0] = neck_part.pd3[0][n2][1] - - self.nodeId[1][n2][1] = neck_part.nodeId[0][n2][2] - self.px[1][n2][1] = neck_part.px[0][n2][2] - self.pd1[1][n2][1] = neck_part.pd1[0][n2][2] - self.pd2[1][n2][1] = neck_part.pd2[0][n2][2] - self.pd3[1][n2][1] = neck_part.pd3[0][n2][2] - - -class JoiningBox4: - def __init__(self, elementsCount, joining_box_3, neck_part, joining_box_right): - self._elementsCount = elementsCount - self._joining_box = True - self._neck_part = False - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - for n2 in range(elementsCount[1]+1): - self.nodeId[0][n2][0] = joining_box_3.nodeId[0][n2][1] - self.px[0][n2][0] = joining_box_3.px[0][n2][1] - self.pd1[0][n2][0] = joining_box_3.pd1[0][n2][1] - self.pd2[0][n2][0] = joining_box_3.pd2[0][n2][1] - self.pd3[0][n2][0] = joining_box_3.pd3[0][n2][1] - - self.nodeId[1][n2][0] = joining_box_3.nodeId[1][n2][1] - self.px[1][n2][0] = joining_box_3.px[1][n2][1] - self.pd1[1][n2][0] = joining_box_3.pd1[1][n2][1] - self.pd2[1][n2][0] = joining_box_3.pd2[1][n2][1] - self.pd3[1][n2][0] = joining_box_3.pd3[1][n2][1] - - self.nodeId[0][n2][1] = joining_box_right.nodeId[1][n2][1] - self.px[0][n2][1] = joining_box_right.px[1][n2][1] - self.pd1[0][n2][1] = joining_box_right.pd1[1][n2][1] - self.pd2[0][n2][1] = joining_box_right.pd2[1][n2][1] - self.pd3[0][n2][1] = joining_box_right.pd3[1][n2][1] - - self.nodeId[1][n2][1] = neck_part.nodeId[0][n2][3] - self.px[1][n2][1] = neck_part.px[0][n2][3] - self.pd1[1][n2][1] = neck_part.pd1[0][n2][3] - self.pd2[1][n2][1] = neck_part.pd2[0][n2][3] - self.pd3[1][n2][1] = neck_part.pd3[0][n2][3] - - class BoxPart: def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): # self._elementsCount = [2, 4, 2] From 175d27ccb2d992868a22887389eca5902807d505 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 19 May 2022 01:57:02 +1200 Subject: [PATCH 26/38] Bifurcation elements --- .../meshtype_3d_solidbifurcation2.py | 4 +- src/scaffoldmaker/utils/bifurcation3d2.py | 519 +++++++++++++++++- 2 files changed, 516 insertions(+), 7 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index ff2f2923..d2b8bd03 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -13,7 +13,7 @@ from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.utils import vector -from scaffoldmaker.utils.bifurcation3d2 import TrifurcationMesh, BranchType, PathNodes +from scaffoldmaker.utils.bifurcation3d2 import TrifurcationMesh, BranchType, PathNodes, BifurcationMesh from scaffoldmaker.utils.meshrefinement import MeshRefinement @@ -294,6 +294,8 @@ def generateBaseMesh(region, options): part1=trifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) + bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii) + trifurcation1.smooth_all_derivatives() annotationGroup = [] diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 35b1971d..56a30932 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -1,6 +1,8 @@ """ Utility functions for generating a 3-D solid bifurcation. """ +import math + from enum import Enum from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier from opencmiss.zinc.element import Element @@ -2160,12 +2162,12 @@ def copyEllipseNodesToTrifurcation(self, ellipse, n3): self.pd3[n3][n2][n1] = ellipse.pd3[n2e][n1e] -class TrifurcationMeshCrotch: +class BifurcationMesh: """ Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates, region): + def __init__(self, fieldModule, coordinates, region, centre, radii): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -2174,10 +2176,12 @@ def __init__(self, fieldModule, coordinates, region): elementsCount = [2, 2, 5] self._elementsCount = elementsCount self._region = region + self._centre = centre + self._radii = radii - self.createTrifurcationMesh3d(fieldModule, coordinates) + self.createBifurcationMesh3d(fieldModule, coordinates) - def createTrifurcationMesh3d(self, fieldmodule, coordinates): + def createBifurcationMesh3d(self, fieldmodule, coordinates): """ Create a trifurcation. :param fieldModule: Zinc fieldModule to create elements in. @@ -2196,11 +2200,514 @@ def createTrifurcationMesh3d(self, fieldmodule, coordinates): mesh = fieldmodule.findMeshByDimension(3) -class CrotchEllipses: - def __init__(self): + elementsCountAcrossShell = 0 + elementsCountAcrossTransition = 1 + shellProportion = 1.0 + coreMajorRadius = 1.0 + coreMinorRadius = 1.0 + # elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 + + xa = [1, 0, 0] + ya = [0, 1, 0] + za = [0, 0, 1] + radius1 = 1.6 + radius2 = 1.3 + radius3 = 0.8 + majorAxis = vector.scaleVector(ya, radius2) + minorAxis = vector.scaleVector(xa, -radius1) + centre1 = vector.addVectors([self._centre, vector.setMagnitude(za, -0.6)] , [1, 1]) + + + ellipse1 = Ellipse2D(centre1, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + # shield = ellipse1.getShield() + # self.generateNodes(nodes, fieldmodule, coordinates, shield) + + majorAxis = vector.scaleVector(ya, radius2) + minorAxis = vector.scaleVector(za, -radius3) + + ellipse2 = Ellipse2D(centre1, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + elementsCount = [ellipse2.elementsCountAcrossMinor, ellipse2.elementsCountAcrossMajor, 1] + + shield = ellipse2.getShield() + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + if n1 <= elementsCount[1]//2: + shield.px[0][n2][n1] = None + + # self.generateNodes(nodes, fieldmodule, coordinates, shield) + + + radius1 = 0.6 + radius2 = 0.6 + hip_length = 2.2 + angle = math.pi/4 + + kv = [0.0, 1.0, 0.0] + Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) + centre = vector.addVectors([centre1, Lv], [1, 1]) + minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) + majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) + + ellipse3 = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + # shield = ellipse3.getShield() + # self.generateNodes(nodes, fieldmodule, coordinates, shield) + + hip_right = Hip(elementsCount) + + pr = [hip_right.nodeId, hip_right.px, hip_right.pd1, hip_right.pd2, hip_right.pd3] + p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] + p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] + p3 = [ellipse3.nodeId[0], ellipse3.px, ellipse3.pd1, ellipse3.pd2, ellipse3.pd3] + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if n3 == 0: + pr[i][n3][n2][n1] = p3[i][n2][n1] + elif n3 == elementsCount[2]: + if n1 <= elementsCount[0]//2: + pr[i][n3][n2][n1] = p1[i][n2][n1] + else: + pr[i][n3][n2][n1] = p2[i][n2][n1] + + self.generateNodes(nodes, fieldmodule, coordinates, hip_right) + + + Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -angle), hip_length) + centre = vector.addVectors([centre1, Lv], [1, 1]) + minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) + majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) + + ellipse4 = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + + # shield = ellipse4.getShield() + # self.generateNodes(nodes, fieldmodule, coordinates, shield) + + hip_left = Hip(elementsCount) + + pl = [hip_left.nodeId, hip_left.px, hip_left.pd1, hip_left.pd2, hip_left.pd3] + p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] + p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] + p3 = [ellipse4.nodeId[0], ellipse4.px, ellipse4.pd1, ellipse4.pd2, ellipse4.pd3] + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if n3 == 0: + pl[i][n3][n2][n1] = p3[i][n2][n1] + elif n3 == elementsCount[2]: + if n1 > elementsCount[0]//2: + pl[i][n3][n2][n1] = p1[i][n2][n1] + else: + if i != 1: + n2r, n1r = n2, elementsCount[0] - n1 + pl[i][n3][n2][n1] = pr[i][n3][n2r][n1r] + + self.generateNodes(nodes, fieldmodule, coordinates, hip_left) + self.generateElements(mesh, fieldmodule, coordinates, hip_left) + a=1 + + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): """ + Create cylinder nodes from coordinates. + :param nodes: nodes from coordinates. + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + self._startNodeIdentifier = nodeIdentifier + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) + self._endNodeIdentifier = nodeIdentifier + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): """ + Create shield nodes from coordinates. + """ + nodeIdentifier = startNodeIdentifier + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) + cache = fieldmodule.createFieldcache() + + for n3 in range(1 + 1): # TODO should change to number of elements alogn, major, minor. + for n2 in range(4 + 1): + for n1 in range(4 + 1): + if part_structure.px[n3][n2][n1]: + node = nodes.createNode(nodeIdentifier, nodetemplate) + part_structure.nodeId[n3][n2][n1] = nodeIdentifier + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + nodeIdentifier += 1 + + return nodeIdentifier + + def generateElements(self, mesh, fieldModule, coordinates, part_structure): + """ + Create cylinder elements from nodes. + :param mesh: + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + self._startElementIdentifier = elementIdentifier + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + self._endElementIdentifier = elementIdentifier + + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, 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 meshGroups: Zinc mesh groups to add elements to. + :return: next elementIdentifier. + """ + elementIdentifier = startElementIdentifier + useCrossDerivatives = False + mesh = fieldmodule.findMeshByDimension(3) + + tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) + eft = tricubichermite.createEftNoCrossDerivatives() + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) + elementtemplate.defineField(coordinates, -1, eft) + + elementtemplate1 = mesh.createElementtemplate() + elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) + + # isEven = (self.elementsCountAcross % 2) == 0 + e1a = 0 + e1b = e1a + 1 + e1z = part_structure._elementsCount[0] - 1 + e1y = e1z - 1 + e2a = 0 + e2b = e2a + 1 + e2c = e2a + 2 + e2z = part_structure._elementsCount[1]-1 + e2y = e2z - 1 + # e2x = e2z - 2 + # for e3 in range(part_structure._elementsCount[2]): + # for e2 in range(part_structure._elementsCount[1]): + # for e1 in range(part_structure._elementsCount[0]): + # eft1 = eft + # scalefactors = None + # nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + # part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + # part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + # part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + # + # if (e2 < e2b) or (e2 > e2y): + # if (e1 < e1b) or (e1 > e1y): + # continue # no element due to triple point closure + # if (e2 < e2a) or (e2 > e2z): + # if e2 < e2a: + # nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + # part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + # elif e2 > e2z: + # nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + # part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + # elif (e2 == e2a) or (e2 == e2z): + # # bottom and top row elements + # if e2 == e2a: + # eft1 = tricubichermite.createEftNoCrossDerivatives() + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # # if not part_structure._shoulder_left: + # # if isinstance(part_structure, BaseLeg): + # # if part_structure._shoulder: + # # if e3 == 0 and e1 == e1b: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + # # [(Node.VALUE_LABEL_D_DS2, []), + # # (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # # [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + # # [(Node.VALUE_LABEL_D_DS1, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # # [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + # # [(Node.VALUE_LABEL_D_DS1, [])]) + # # if e3 == 0: + # # if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): + # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + # # if (e1 == e1b) or (e1 == e1y): + # # # # map bottom triple point element + # # if e1 == e1b: + # # # if e3 != 2: + # # # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # if part_structure._shoulder: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + # # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # else: + # # remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + # # [(Node.VALUE_LABEL_D_DS1, []), + # # (Node.VALUE_LABEL_D_DS3, [1])]) + # # elif e2 == e2z: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [-1.0] + # # if isinstance(part_structure, BaseLeg): + # # if part_structure._shoulder and e3 == 0 and e1 == e1b: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # # remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # # remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # # if (e1 == e1b) or (e1 == e1y): + # # # map top triple point element + # # if e1 == e1b: + # # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # if e3 == 0: + # # if part_structure._shoulder: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # if part_structure._shoulder: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + # # + # # elif (e2 == e2b) or (e2 == e2y): + # # if (e1 <= e1a) or (e1 >= e1z): + # # if e1 < e1a: + # # e2r = e1 + # # if e2 == e2b: + # # nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], + # # part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + # # if e2 == e2y: + # # e2r = 2*part_structure._elementsCount[1] - e1-1 + # # nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], + # # part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + # # elif e1 == e1a: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [-1.0] + # # if e2 == e2b: + # # if e3 == part_structure._elementsCount[2] // 2 + 1: + # # e3r = e3-1 # to join upper leg with the lower leg. + # # nids[0] = part_structure.nodeId[e3r][e2a][e1b] + # # nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + # # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + # # nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + # # nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + # # else: + # # nids[0] = part_structure.nodeId[e3][e2a][e1b] + # # nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + # # + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # else: + # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # tripleN = [5, 7] + # # remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # elif e2 == e2y: + # # nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + # # nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + # # tripleN = [6, 8] + # # remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # # 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] ) ]) + # # if e3 == 0: + # # if part_structure._shoulder: + # # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) + # # elif e1 == e1z: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if e2 == e2b: + # # nids[4] = part_structure.nodeId[e3][e2a][e1z] + # # nids[6] = part_structure.nodeId[e3+1][e2a][e1z] + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [ -1.0 ] + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + # # else: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # # else: + # # 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] = part_structure.nodeId[e3][e2z+1][e1z] + # # nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # elif e1 > e1z: + # # e2r = part_structure._elementsCount[0] - e1 + # # if e2 == e2b: + # # nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], + # # part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + # # elif e2 == e2y: + # # e2r = e2z+e1-e1z + # # nids[1] = part_structure.nodeId[e3][e2r][e1z] + # # nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + # # nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + # # nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + # # elif e1 == e1b: + # # if e2 == e2b: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # if part_structure._shoulder: + # # if e3 == 0: + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [-1.0] + # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # # + # # if e2 == e2y: + # # if part_structure._shoulder: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if e3 == 0: + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [-1.0] + # # remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, + # # [(Node.VALUE_LABEL_D_DS2, []), + # # (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # # + # # + # # elif e1 == e1y: + # # if e2 == e2b: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if part_structure._shoulder_left: + # # if e3 == 0: + # # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # + # # else: + # # if part_structure._shoulder_left: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if e3 == 0 and e2 <= e2b: + # # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # # + # # + # # + # # else: + # # if e1 < e1a: + # # nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + # # part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + # # elif e1 == e1a: + # # # map left column elements + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [ -1.0 ] + # # 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])]) + # # if e3 == 0 and part_structure._shoulder: + # # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + # # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # + # # elif e1 == e1b: + # # eft1 = tricubichermite.createEftNoCrossDerivatives() + # # if e3 == 0 and part_structure._shoulder: + # # setEftScaleFactorIds(eft1, [1], []) + # # scalefactors = [-1.0] + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # + # + # + # if not all(nids): + # continue + # + # if eft1 is not eft: + # elementtemplate1.defineField(coordinates, -1, eft1) + # element = mesh.createElement(elementIdentifier, elementtemplate1) + # else: + # element = mesh.createElement(elementIdentifier, elementtemplate) + # result2 = element.setNodesByIdentifier(eft1, nids) + # if scalefactors: + # result3 = element.setScaleFactors(eft1, scalefactors) + # else: + # result3 = 7 + # #print('create element shield', elementIdentifier, result2, result3, nids) + # part_structure.elementId[e3][e2][e1] = elementIdentifier + # elementIdentifier += 1 + # + # for meshGroup in meshGroups: + # meshGroup.addElement(element) + + return elementIdentifier + + +class Hip: + def __init__(self, elementsCount): + self._elementsCount = elementsCount + self._joining_box = True + + elementsCount = elementsCount + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + + class BoxPart: From d2fab56fb462e600e1e14b9b47c1f1f44c6ec7d5 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 20 May 2022 16:22:38 +1200 Subject: [PATCH 27/38] Add the cylinders for the legs --- .../meshtype_3d_solidbifurcation2.py | 2 +- src/scaffoldmaker/utils/bifurcation3d2.py | 646 ++++++++++-------- 2 files changed, 354 insertions(+), 294 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index d2b8bd03..42b09076 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -296,7 +296,7 @@ def generateBaseMesh(region, options): bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii) - trifurcation1.smooth_all_derivatives() + # trifurcation1.smooth_all_derivatives() annotationGroup = [] return annotationGroup diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 56a30932..bca74164 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -2179,6 +2179,11 @@ def __init__(self, fieldModule, coordinates, region, centre, radii): self._centre = centre self._radii = radii + self._coordinates = coordinates + self._fieldmodule = fieldModule + self._nodes = fieldModule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + self._mesh = fieldModule.findMeshByDimension(3) + self.createBifurcationMesh3d(fieldModule, coordinates) def createBifurcationMesh3d(self, fieldmodule, coordinates): @@ -2215,7 +2220,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): radius3 = 0.8 majorAxis = vector.scaleVector(ya, radius2) minorAxis = vector.scaleVector(xa, -radius1) - centre1 = vector.addVectors([self._centre, vector.setMagnitude(za, -0.6)] , [1, 1]) + centre1 = vector.addVectors([self._centre, vector.setMagnitude(za, -0.0)] , [1, 1]) ellipse1 = Ellipse2D(centre1, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], @@ -2243,10 +2248,10 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # self.generateNodes(nodes, fieldmodule, coordinates, shield) - radius1 = 0.6 - radius2 = 0.6 - hip_length = 2.2 - angle = math.pi/4 + radius1 = 0.8 + radius2 = 0.8 + hip_length = 1.6 + angle = math.pi/2*0.7 kv = [0.0, 1.0, 0.0] Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) @@ -2260,7 +2265,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # shield = ellipse3.getShield() # self.generateNodes(nodes, fieldmodule, coordinates, shield) - hip_right = Hip(elementsCount) + hip_right = Hip(elementsCount, 'right') pr = [hip_right.nodeId, hip_right.px, hip_right.pd1, hip_right.pd2, hip_right.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] @@ -2279,6 +2284,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pr[i][n3][n2][n1] = p2[i][n2][n1] self.generateNodes(nodes, fieldmodule, coordinates, hip_right) + self.generateElements(mesh, fieldmodule, coordinates, hip_right) Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -angle), hip_length) @@ -2293,7 +2299,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # shield = ellipse4.getShield() # self.generateNodes(nodes, fieldmodule, coordinates, shield) - hip_left = Hip(elementsCount) + hip_left = Hip(elementsCount, 'left') pl = [hip_left.nodeId, hip_left.px, hip_left.pd1, hip_left.pd2, hip_left.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] @@ -2315,6 +2321,19 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateNodes(nodes, fieldmodule, coordinates, hip_left) self.generateElements(mesh, fieldmodule, coordinates, hip_left) + + + pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 5.0, [4, 4, 7], attach_bottom=False) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, [4, 4, 7], hip_right, attach_bottom=False) + cylinder = bc.get_cylinder() + + pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 5.0, [4, 4, 7], attach_bottom=False) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, [4, 4, 7], hip_left, attach_bottom=False) + cylinder = bc.get_cylinder() a=1 def generateNodes(self, nodes, fieldModule, coordinates, part_structure): @@ -2404,298 +2423,339 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif e2z = part_structure._elementsCount[1]-1 e2y = e2z - 1 # e2x = e2z - 2 - # for e3 in range(part_structure._elementsCount[2]): - # for e2 in range(part_structure._elementsCount[1]): - # for e1 in range(part_structure._elementsCount[0]): - # eft1 = eft - # scalefactors = None - # nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], - # part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], - # part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], - # part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] - # - # if (e2 < e2b) or (e2 > e2y): - # if (e1 < e1b) or (e1 > e1y): - # continue # no element due to triple point closure - # if (e2 < e2a) or (e2 > e2z): - # if e2 < e2a: - # nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], - # part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] - # elif e2 > e2z: - # nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], - # part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] - # elif (e2 == e2a) or (e2 == e2z): - # # bottom and top row elements - # if e2 == e2a: - # eft1 = tricubichermite.createEftNoCrossDerivatives() - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # # if not part_structure._shoulder_left: - # # if isinstance(part_structure, BaseLeg): - # # if part_structure._shoulder: - # # if e3 == 0 and e1 == e1b: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - # # [(Node.VALUE_LABEL_D_DS2, []), - # # (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # # [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - # # [(Node.VALUE_LABEL_D_DS1, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # # [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - # # [(Node.VALUE_LABEL_D_DS1, [])]) - # # if e3 == 0: - # # if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): - # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - # # if (e1 == e1b) or (e1 == e1y): - # # # # map bottom triple point element - # # if e1 == e1b: - # # # if e3 != 2: - # # # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # if part_structure._shoulder: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - # # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # else: - # # remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, - # # [(Node.VALUE_LABEL_D_DS1, []), - # # (Node.VALUE_LABEL_D_DS3, [1])]) - # # elif e2 == e2z: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [-1.0] - # # if isinstance(part_structure, BaseLeg): - # # if part_structure._shoulder and e3 == 0 and e1 == e1b: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # # remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # # remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # # if (e1 == e1b) or (e1 == e1y): - # # # map top triple point element - # # if e1 == e1b: - # # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # if e3 == 0: - # # if part_structure._shoulder: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # if part_structure._shoulder: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) - # # - # # elif (e2 == e2b) or (e2 == e2y): - # # if (e1 <= e1a) or (e1 >= e1z): - # # if e1 < e1a: - # # e2r = e1 - # # if e2 == e2b: - # # nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], - # # part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] - # # if e2 == e2y: - # # e2r = 2*part_structure._elementsCount[1] - e1-1 - # # nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], - # # part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] - # # elif e1 == e1a: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [-1.0] - # # if e2 == e2b: - # # if e3 == part_structure._elementsCount[2] // 2 + 1: - # # e3r = e3-1 # to join upper leg with the lower leg. - # # nids[0] = part_structure.nodeId[e3r][e2a][e1b] - # # nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - # # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - # # nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] - # # nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] - # # else: - # # nids[0] = part_structure.nodeId[e3][e2a][e1b] - # # nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - # # - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # else: - # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # tripleN = [5, 7] - # # remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # elif e2 == e2y: - # # nids[1] = part_structure.nodeId[e3][e2z+1][e1b] - # # nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] - # # tripleN = [6, 8] - # # remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # # 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] ) ]) - # # if e3 == 0: - # # if part_structure._shoulder: - # # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) - # # elif e1 == e1z: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if e2 == e2b: - # # nids[4] = part_structure.nodeId[e3][e2a][e1z] - # # nids[6] = part_structure.nodeId[e3+1][e2a][e1z] - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [ -1.0 ] - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - # # else: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # # else: - # # 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] = part_structure.nodeId[e3][e2z+1][e1z] - # # nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] - # # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # elif e1 > e1z: - # # e2r = part_structure._elementsCount[0] - e1 - # # if e2 == e2b: - # # nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], - # # part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] - # # elif e2 == e2y: - # # e2r = e2z+e1-e1z - # # nids[1] = part_structure.nodeId[e3][e2r][e1z] - # # nids[3] = part_structure.nodeId[e3+1][e2r][e1z] - # # nids[5] = part_structure.nodeId[e3][e2r+1][e1z] - # # nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] - # # elif e1 == e1b: - # # if e2 == e2b: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # if part_structure._shoulder: - # # if e3 == 0: - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [-1.0] - # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # # - # # if e2 == e2y: - # # if part_structure._shoulder: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if e3 == 0: - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [-1.0] - # # remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, - # # [(Node.VALUE_LABEL_D_DS2, []), - # # (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # # - # # - # # elif e1 == e1y: - # # if e2 == e2b: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if part_structure._shoulder_left: - # # if e3 == 0: - # # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # - # # else: - # # if part_structure._shoulder_left: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if e3 == 0 and e2 <= e2b: - # # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # # - # # - # # - # # else: - # # if e1 < e1a: - # # nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - # # part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] - # # elif e1 == e1a: - # # # map left column elements - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [ -1.0 ] - # # 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])]) - # # if e3 == 0 and part_structure._shoulder: - # # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, - # # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # - # # elif e1 == e1b: - # # eft1 = tricubichermite.createEftNoCrossDerivatives() - # # if e3 == 0 and part_structure._shoulder: - # # setEftScaleFactorIds(eft1, [1], []) - # # scalefactors = [-1.0] - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # - # - # - # if not all(nids): - # continue - # - # if eft1 is not eft: - # elementtemplate1.defineField(coordinates, -1, eft1) - # element = mesh.createElement(elementIdentifier, elementtemplate1) - # else: - # element = mesh.createElement(elementIdentifier, elementtemplate) - # result2 = element.setNodesByIdentifier(eft1, nids) - # if scalefactors: - # result3 = element.setScaleFactors(eft1, scalefactors) - # else: - # result3 = 7 - # #print('create element shield', elementIdentifier, result2, result3, nids) - # part_structure.elementId[e3][e2][e1] = elementIdentifier - # elementIdentifier += 1 - # - # for meshGroup in meshGroups: - # meshGroup.addElement(element) + for e3 in range(part_structure._elementsCount[2]): + for e2 in range(part_structure._elementsCount[1]): + for e1 in range(part_structure._elementsCount[0]): + eft1 = eft + scalefactors = None + nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + # if not part_structure._shoulder_left: + # if isinstance(part_structure, BaseLeg): + # if part_structure._shoulder: + # if e3 == 0 and e1 == e1b: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), + # (Node.VALUE_LABEL_D_DS3, [1])]) + + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if part_structure._side == 'right': + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if e1 == e1y: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if e1 == e1b: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + + # else: + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + # if e3 == 0: + # if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): + # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + if (e1 == e1b) or (e1 == e1y): + # # map bottom triple point element + if e1 == e1b: + # if e3 != 2: + # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + # if part_structure._shoulder_left: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # else: + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # else: + # if part_structure._shoulder: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # else: + # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # else: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + else: + # if part_structure._shoulder_left: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # else: + # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder and e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # TODO if e3 == -1 + remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + if part_structure._side == 'right': + if e1 == e1y: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + elif part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # if e3 == 0: + # # if part_structure._shoulder: + # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # if part_structure._shoulder: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*part_structure._elementsCount[1] - e1-1 + nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + + # if part_structure._shoulder_left: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # else: + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # else: + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + 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] ) ]) + # if e3 == 0: + # if part_structure._shoulder: + # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.nodeId[e3+1][e2a][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + # if part_structure._shoulder_left: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + # else: + # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + # else: + 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] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e1 > e1z: + e2r = part_structure._elementsCount[0] - e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = part_structure.nodeId[e3][e2r][e1z] + nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + # if part_structure._shoulder_left: + # if e3 == 0: + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + # if part_structure._shoulder: + # if e3 == 0: + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + + # if e2 == e2y: + # if part_structure._shoulder: + # eft1 = tricubichermite.createEftNoCrossDerivatives() + # if e3 == 0: + # setEftScaleFactorIds(eft1, [1], []) + # scalefactors = [-1.0] + # remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS2, []), + # (Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + + + elif e1 == e1y: + if e2 == e2b or e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._side == 'right': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + + + + # if part_structure._shoulder_left: + # if e3 == 0: + # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + + # else: + # if part_structure._shoulder_left: + # eft1 = tricubichermite.createEftNoCrossDerivatives() + # if e3 == 0 and e2 <= e2b: + # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) + # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + + + + else: + if e1 < e1a: + nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + 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])]) + if e3 == 0 and part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and part_structure._shoulder: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + + + + if not all(nids): + continue + + if eft1 is not eft: + elementtemplate1.defineField(coordinates, -1, eft1) + element = mesh.createElement(elementIdentifier, elementtemplate1) + else: + element = mesh.createElement(elementIdentifier, elementtemplate) + result2 = element.setNodesByIdentifier(eft1, nids) + if scalefactors: + result3 = element.setScaleFactors(eft1, scalefactors) + else: + result3 = 7 + #print('create element shield', elementIdentifier, result2, result3, nids) + part_structure.elementId[e3][e2][e1] = elementIdentifier + elementIdentifier += 1 + + for meshGroup in meshGroups: + meshGroup.addElement(element) return elementIdentifier class Hip: - def __init__(self, elementsCount): + def __init__(self, elementsCount, side): self._elementsCount = elementsCount - self._joining_box = True + self._side = side elementsCount = elementsCount From 766cdb70903f5dbaed99955da66e052ac7eec55c Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Wed, 27 Jul 2022 07:09:15 +1200 Subject: [PATCH 28/38] Fix the lower limbs elements part1 --- src/scaffoldmaker/utils/bifurcation3d2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index bca74164..ff426a5a 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -2458,9 +2458,11 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, # [(Node.VALUE_LABEL_D_DS2, []), # (Node.VALUE_LABEL_D_DS3, [1])]) - + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + if part_structure._side == 'right': remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) @@ -2479,8 +2481,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) + # else: # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, From aff8711fbc9b00544e896b4adc951db028d458cc Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 28 Jul 2022 12:21:40 +1200 Subject: [PATCH 29/38] Fix derivatives for lower limb elementes --- .../meshtype_3d_solidbifurcation2.py | 7 +- src/scaffoldmaker/utils/bifurcation3d2.py | 197 ++++++++++++++---- 2 files changed, 160 insertions(+), 44 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 42b09076..fd574734 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -103,6 +103,7 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Number of elements across shell': 0, 'Number of elements across transition': 1, 'Shell element thickness proportion': 1.0, + 'Pre-fit configuration': True, 'Use cross derivatives': False, 'Refine': False, 'Refine number of elements across major': 1, @@ -138,6 +139,7 @@ def getOrderedOptionNames(): 'Number of elements across shell', 'Number of elements across transition', 'Shell element thickness proportion', + 'Pre-fit configuration', 'Refine', 'Refine number of elements across major', ] @@ -283,7 +285,7 @@ def generateBaseMesh(region, options): head_cylinder = trifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], head_length/head_number_of_elements, - [elementsCountAcrossMajor,elementsCountAcrossMajor, head_number_of_elements], path_list=path_list, + [elementsCountAcrossMajor, elementsCountAcrossMajor, head_number_of_elements], path_list=path_list, part1=neck_cyliner_shield, branch_type=4) cap = trifurcation1.create_branch_cap(head_cylinder, head_radius) @@ -294,7 +296,8 @@ def generateBaseMesh(region, options): part1=trifurcation1._torso_upper_part, branch_type=4, attach_bottom=False) - bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii) + bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii, + part1=lower_torso_cylinder) # trifurcation1.smooth_all_derivatives() diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index ff426a5a..900cefb9 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -60,10 +60,10 @@ def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, ele attach_bottom=True): if attach_bottom: n3, n3p = 0, -1 - node_ranges = [1, elements_count[2] + 1] + node_ranges = [1, elements_count[2]] else: n3, n3p = -1, 0 - node_ranges = [0, elements_count[2]] + node_ranges = [0, elements_count[2] - 1] centralPath = ScaffoldPackage(MeshType_1d_path1, { 'scaffoldSettings': { 'Coordinate dimensions': 3, @@ -2167,7 +2167,7 @@ class BifurcationMesh: Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates, region, centre, radii): + def __init__(self, fieldModule, coordinates, region, centre, radii, part1=None): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -2178,6 +2178,7 @@ def __init__(self, fieldModule, coordinates, region, centre, radii): self._region = region self._centre = centre self._radii = radii + self._part1 = part1 self._coordinates = coordinates self._fieldmodule = fieldModule @@ -2252,10 +2253,16 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): radius2 = 0.8 hip_length = 1.6 angle = math.pi/2*0.7 + hip_distance = 1.4 # distance from belly button. kv = [0.0, 1.0, 0.0] + x_hip_joint = vector.addVectors([centre1, + vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, math.pi/4), + hip_distance)], [1, 1]) Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) - centre = vector.addVectors([centre1, Lv], [1, 1]) + # Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) + centre = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) + # centre = vector.addVectors([centre1, Lv], [1, 1]) minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) @@ -2269,6 +2276,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pr = [hip_right.nodeId, hip_right.px, hip_right.pd1, hip_right.pd2, hip_right.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] + p1v2 = [self._part1._shield.nodeId[0], self._part1._shield.px[0], self._part1._shield.pd1[0], self._part1._shield.pd2[0], self._part1._shield.pd3[0]] p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] p3 = [ellipse3.nodeId[0], ellipse3.px, ellipse3.pd1, ellipse3.pd2, ellipse3.pd3] for n3 in range(elementsCount[2] + 1): @@ -2279,16 +2287,28 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pr[i][n3][n2][n1] = p3[i][n2][n1] elif n3 == elementsCount[2]: if n1 <= elementsCount[0]//2: - pr[i][n3][n2][n1] = p1[i][n2][n1] + if i != 1: + pr[i][n3][n2][n1] = p1v2[i][n2][n1] else: pr[i][n3][n2][n1] = p2[i][n2][n1] self.generateNodes(nodes, fieldmodule, coordinates, hip_right) + # Add the common nodeIds + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if n3 == elementsCount[2]: + if n1 <= elementsCount[0]//2: + pr[i][n3][n2][n1] = p1v2[i][n2][n1] self.generateElements(mesh, fieldmodule, coordinates, hip_right) - + x_hip_joint = vector.addVectors([centre1, + vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -math.pi/4), + hip_distance)], [1, 1]) Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -angle), hip_length) - centre = vector.addVectors([centre1, Lv], [1, 1]) + centre = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) + # centre = vector.addVectors([centre1, Lv], [1, 1]) minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) @@ -2313,23 +2333,31 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pl[i][n3][n2][n1] = p3[i][n2][n1] elif n3 == elementsCount[2]: if n1 > elementsCount[0]//2: - pl[i][n3][n2][n1] = p1[i][n2][n1] + if i!= 1: + pl[i][n3][n2][n1] = p1v2[i][n2][n1] else: if i != 1: n2r, n1r = n2, elementsCount[0] - n1 pl[i][n3][n2][n1] = pr[i][n3][n2r][n1r] self.generateNodes(nodes, fieldmodule, coordinates, hip_left) + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if n3 == elementsCount[2]: + if n1 > elementsCount[0]//2: + pl[i][n3][n2][n1] = p1v2[i][n2][n1] self.generateElements(mesh, fieldmodule, coordinates, hip_left) - pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 5.0, [4, 4, 7], attach_bottom=False) + pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, path_list, [4, 4, 7], hip_right, attach_bottom=False) cylinder = bc.get_cylinder() - pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 5.0, [4, 4, 7], attach_bottom=False) + pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, path_list, [4, 4, 7], hip_left, attach_bottom=False) @@ -2458,6 +2486,11 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, # [(Node.VALUE_LABEL_D_DS2, []), # (Node.VALUE_LABEL_D_DS3, [1])]) + if part_structure._side == 'right': + # if e3,e2,e1 = 0, 0, 2 + if e1 == e1y: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, @@ -2473,14 +2506,22 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) elif part_structure._side == 'left': - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) if e1 == e1b: + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, [1])]) + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) else: remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) # else: @@ -2543,19 +2584,57 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) # TODO if e3 == -1 - remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) if part_structure._side == 'right': if e1 == e1y: remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) else: - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif part_structure._side == 'left': - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + if e1 == e1b: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + # [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + # [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) if (e1 == e1b) or (e1 == e1y): # map top triple point element @@ -2606,14 +2685,36 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # else: - tripleN = [5, 7] + tripleN = [5, 7] if part_structure._side == 'right' else [5] remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] - tripleN = [6, 8] + tripleN = [6, 8] if part_structure._side == 'right' else [6] remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [ 1, 2, 3, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) + if part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + if e2 == e2b: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2y: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + elif part_structure._side == 'right': + # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + # [(Node.VALUE_LABEL_D_DS1, [1]), + # (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 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] ) ]) # if e3 == 0: # if part_structure._shoulder: @@ -2635,10 +2736,21 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) # else: remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + if part_structure._side == 'right': + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2y: nids[5] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # if e3,e2,e1 = 0 2 3 + if part_structure._side == 'right': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) elif e1 > e1z: e2r = part_structure._elementsCount[0] - e1 if e2 == e2b: @@ -2653,27 +2765,26 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1b: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() - # if part_structure._shoulder_left: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # if part_structure._shoulder: - # if e3 == 0: - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - - # if e2 == e2y: - # if part_structure._shoulder: - # eft1 = tricubichermite.createEftNoCrossDerivatives() - # if e3 == 0: - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), - # (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + if part_structure._side == 'left': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._side == 'left': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) elif e1 == e1y: @@ -2684,6 +2795,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) From c3c849c661aba5f79f0b0f2575e4fe6561b045f4 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 29 Jul 2022 07:53:39 +1200 Subject: [PATCH 30/38] stickman control for legs --- .../meshtypes/meshtype_1d_stickman1.py | 22 +++++-- .../meshtype_3d_solidbifurcation2.py | 47 ++++++++------ src/scaffoldmaker/utils/bifurcation3d2.py | 61 ++++++++++--------- 3 files changed, 78 insertions(+), 52 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py index 23b34b64..b2fc6f98 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py @@ -52,6 +52,7 @@ def generateBaseMesh(cls, region, options): coordinates = findOrCreateFieldCoordinates(fieldmodule, components_count=3) cache = fieldmodule.createFieldcache() + six_stick = True ################# # Create nodes ################# @@ -63,9 +64,13 @@ def generateBaseMesh(cls, region, options): nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) nodeIdentifier = 1 - x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], - [-0.25, 0.0, 0.81], [-0.5, 0.0, 0.87], [-0.25, 0.0, 0.25], [-0.5, 0.0, 0.0], - [0.25, 0.0, 0.81], [0.5, 0.0, 0.87], [0.25, 0.0, 0.25], [0.5, 0.0, 0.0]] + if six_stick: + x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], + [-0.25, 0.0, 0.81], [-0.01, 0.0, 0.0], [0.25, 0.0, 0.81], [0.01, 0.0, 0.0]] + else: + x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], + [-0.25, 0.0, 0.81], [-0.25, 0.0, 0.25], [0.25, 0.0, 0.81], [0.25, 0.0, 0.25], [-0.5, 0.0, 0.87] , [-0.5, 0.0, 0.0], + [0.5, 0.0, 0.87], [0.5, 0.0, 0.0]] for x in x_list: node = nodes.createNode(nodeIdentifier, nodetemplate) @@ -85,9 +90,14 @@ def generateBaseMesh(cls, region, options): result = elementtemplate.defineField(coordinates, -1, eft) elementIdentifier = 1 - lines = [[1, 2], [2, 3], - [2, 4], [4, 5], [3, 6], [6, 7], - [2, 8], [8, 9], [3, 10], [10, 11]] + if six_stick: + lines = [[1, 2], [2, 3], + [2, 4], [3, 5], + [2, 6], [3, 7]] + else: + lines = [[1, 2], [2, 3], + [2, 4], [3, 5], [2, 6], [3, 7], + [4, 8], [5, 9], [6, 10], [7, 11]] for e in lines: element = mesh.createElement(elementIdentifier, elementtemplate) element.setNodesByIdentifier(eft, e) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index fd574734..f5cf616e 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -45,11 +45,11 @@ class MeshType_3d_solidbifurcation2(Scaffold_base): 'Coordinate dimensions': 3, } }), - 'control curves1': ScaffoldPackage(MeshType_1d_stickman1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - } - }) + # 'control curves1': ScaffoldPackage(MeshType_1d_stickman1, { + # 'scaffoldSettings': { + # 'Coordinate dimensions': 3, + # } + # }) } @staticmethod @@ -59,10 +59,10 @@ def getName(): @classmethod def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] - centralPathOption1 = cls.centralPathDefaultScaffoldPackages['control curves1'] + # centralPathOption1 = cls.centralPathDefaultScaffoldPackages['control curves1'] options = { 'Central path': copy.deepcopy(centralPathOption), - 'Central path1': copy.deepcopy(centralPathOption1), + # 'Central path1': copy.deepcopy(centralPathOption1), 'Armpit': [1.2, 0.0, 1.0], 'Head length': 1.0, 'Head number of elements': 5, @@ -114,7 +114,7 @@ def getDefaultOptions(cls, parameterSetName='Default'): def getOrderedOptionNames(): return [ 'Central path', - 'Central path1', + # 'Central path1', 'Armpit', 'Head length', 'Head number of elements', @@ -243,15 +243,28 @@ def generateBaseMesh(region, options): centralPath.generate(tmpRegion) cx = extractPathParametersFromRegion(tmpRegion, [Node.VALUE_LABEL_VALUE])[0] - deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - right_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) - if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: - right_arm_angle = -right_arm_angle + def limb_angle(p1, p2): + deltacx = vector.vectorRejection(vector.addVectors([p2, p1], [1, -1]), [0.0, 1.0, 0.0]) + right_arm_angle = vector.angleBetweenVectors([p2[0], 0.0, 0.0], deltacx) + if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: + right_arm_angle = -right_arm_angle + return right_arm_angle + + # deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + # right_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) + # if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: + # right_arm_angle = -right_arm_angle + # + # deltacx = vector.vectorRejection(vector.addVectors([cx[5], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) + # left_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) + # if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: + # left_arm_angle = -left_arm_angle + + right_arm_angle = limb_angle(cx[1], cx[3]) + left_arm_angle = limb_angle(cx[1], cx[5]) + right_leg_angle = limb_angle(cx[2], cx[4]) + left_leg_angle = limb_angle(cx[2], cx[6]) - deltacx = vector.vectorRejection(vector.addVectors([cx[7], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - left_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) - if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: - left_arm_angle = -left_arm_angle trifurcation1 = TrifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, @@ -297,7 +310,7 @@ def generateBaseMesh(region, options): attach_bottom=False) bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii, - part1=lower_torso_cylinder) + right_leg_angle, left_leg_angle, part1=lower_torso_cylinder) # trifurcation1.smooth_all_derivatives() diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 900cefb9..030b3d2d 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -2167,7 +2167,7 @@ class BifurcationMesh: Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates, region, centre, radii, part1=None): + def __init__(self, fieldModule, coordinates, region, centre, radii, right_leg_angle, left_leg_angle, part1=None): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -2178,6 +2178,8 @@ def __init__(self, fieldModule, coordinates, region, centre, radii, part1=None): self._region = region self._centre = centre self._radii = radii + self.right_leg_angle = right_leg_angle + self.left_leg_angle = left_leg_angle self._part1 = part1 self._coordinates = coordinates @@ -2252,7 +2254,8 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): radius1 = 0.8 radius2 = 0.8 hip_length = 1.6 - angle = math.pi/2*0.7 + # angle = math.pi/2*0.7 + angle = self.left_leg_angle hip_distance = 1.4 # distance from belly button. kv = [0.0, 1.0, 0.0] @@ -2272,9 +2275,9 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # shield = ellipse3.getShield() # self.generateNodes(nodes, fieldmodule, coordinates, shield) - hip_right = Hip(elementsCount, 'right') + hip_left = Hip(elementsCount, 'left') - pr = [hip_right.nodeId, hip_right.px, hip_right.pd1, hip_right.pd2, hip_right.pd3] + pr = [hip_left.nodeId, hip_left.px, hip_left.pd1, hip_left.pd2, hip_left.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] p1v2 = [self._part1._shield.nodeId[0], self._part1._shield.px[0], self._part1._shield.pd1[0], self._part1._shield.pd2[0], self._part1._shield.pd3[0]] p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] @@ -2292,7 +2295,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): else: pr[i][n3][n2][n1] = p2[i][n2][n1] - self.generateNodes(nodes, fieldmodule, coordinates, hip_right) + self.generateNodes(nodes, fieldmodule, coordinates, hip_left) # Add the common nodeIds for n3 in range(elementsCount[2] + 1): for n2 in range(elementsCount[1] + 1): @@ -2301,12 +2304,12 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): if n3 == elementsCount[2]: if n1 <= elementsCount[0]//2: pr[i][n3][n2][n1] = p1v2[i][n2][n1] - self.generateElements(mesh, fieldmodule, coordinates, hip_right) + self.generateElements(mesh, fieldmodule, coordinates, hip_left) x_hip_joint = vector.addVectors([centre1, vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -math.pi/4), hip_distance)], [1, 1]) - Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -angle), hip_length) + Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -self.right_leg_angle), hip_length) centre = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) # centre = vector.addVectors([centre1, Lv], [1, 1]) minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) @@ -2319,9 +2322,9 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): # shield = ellipse4.getShield() # self.generateNodes(nodes, fieldmodule, coordinates, shield) - hip_left = Hip(elementsCount, 'left') + hip_right = Hip(elementsCount, 'right') - pl = [hip_left.nodeId, hip_left.px, hip_left.pd1, hip_left.pd2, hip_left.pd3] + pl = [hip_right.nodeId, hip_right.px, hip_right.pd1, hip_right.pd2, hip_right.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] p3 = [ellipse4.nodeId[0], ellipse4.px, ellipse4.pd1, ellipse4.pd2, ellipse4.pd3] @@ -2340,7 +2343,7 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): n2r, n1r = n2, elementsCount[0] - n1 pl[i][n3][n2][n1] = pr[i][n3][n2r][n1r] - self.generateNodes(nodes, fieldmodule, coordinates, hip_left) + self.generateNodes(nodes, fieldmodule, coordinates, hip_right) for n3 in range(elementsCount[2] + 1): for n2 in range(elementsCount[1] + 1): for n1 in range(elementsCount[0] + 1): @@ -2348,19 +2351,19 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): if n3 == elementsCount[2]: if n1 > elementsCount[0]//2: pl[i][n3][n2][n1] = p1v2[i][n2][n1] - self.generateElements(mesh, fieldmodule, coordinates, hip_left) + self.generateElements(mesh, fieldmodule, coordinates, hip_right) - pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) + pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, - path_list, [4, 4, 7], hip_right, attach_bottom=False) + path_list, [4, 4, 7], hip_left, attach_bottom=False) cylinder = bc.get_cylinder() - pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) + pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, - path_list, [4, 4, 7], hip_left, attach_bottom=False) + path_list, [4, 4, 7], hip_right, attach_bottom=False) cylinder = bc.get_cylinder() a=1 @@ -2486,7 +2489,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, # [(Node.VALUE_LABEL_D_DS2, []), # (Node.VALUE_LABEL_D_DS3, [1])]) - if part_structure._side == 'right': + if part_structure._side == 'left': # if e3,e2,e1 = 0, 0, 2 if e1 == e1y: remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, @@ -2496,7 +2499,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - if part_structure._side == 'right': + if part_structure._side == 'left': remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) if e1 == e1y: @@ -2505,7 +2508,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - elif part_structure._side == 'left': + elif part_structure._side == 'right': if e1 == e1b: remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) @@ -2586,7 +2589,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # TODO if e3 == -1 remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - if part_structure._side == 'right': + if part_structure._side == 'left': if e1 == e1y: remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) @@ -2599,7 +2602,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - elif part_structure._side == 'left': + elif part_structure._side == 'right': # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, # [(Node.VALUE_LABEL_D_DS1, [1])]) # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, @@ -2685,15 +2688,15 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # else: - tripleN = [5, 7] if part_structure._side == 'right' else [5] + tripleN = [5, 7] if part_structure._side == 'left' else [5] remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] - tripleN = [6, 8] if part_structure._side == 'right' else [6] + tripleN = [6, 8] if part_structure._side == 'left' else [6] remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) - if part_structure._side == 'left': + if part_structure._side == 'right': remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) if e2 == e2b: remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, @@ -2709,7 +2712,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - elif part_structure._side == 'right': + elif part_structure._side == 'left': # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, # [(Node.VALUE_LABEL_D_DS1, [1]), # (Node.VALUE_LABEL_D_DS3, [1])]) @@ -2736,7 +2739,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) # else: remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - if part_structure._side == 'right': + if part_structure._side == 'left': remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2y: @@ -2744,7 +2747,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # if e3,e2,e1 = 0 2 3 - if part_structure._side == 'right': + if part_structure._side == 'left': setEftScaleFactorIds(eft1, [1], []) scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, @@ -2765,7 +2768,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1b: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() - if part_structure._side == 'left': + if part_structure._side == 'right': setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, @@ -2776,7 +2779,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS3, [1])]) else: eft1 = tricubichermite.createEftNoCrossDerivatives() - if part_structure._side == 'left': + if part_structure._side == 'right': setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, @@ -2790,7 +2793,7 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1y: if e2 == e2b or e2 == e2y: eft1 = tricubichermite.createEftNoCrossDerivatives() - if part_structure._side == 'right': + if part_structure._side == 'left': setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, From 00077a94c02e525ac46f01ea7d9308d5cdd44053 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 29 Jul 2022 10:04:54 +1200 Subject: [PATCH 31/38] Clean up a little bit --- .../meshtype_3d_solidbifurcation2.py | 83 +++++++++---------- src/scaffoldmaker/utils/bifurcation3d2.py | 42 +++++++++- src/scaffoldmaker/utils/cylindermesh.py | 3 + 3 files changed, 81 insertions(+), 47 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index f5cf616e..0fa8b834 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -45,11 +45,6 @@ class MeshType_3d_solidbifurcation2(Scaffold_base): 'Coordinate dimensions': 3, } }), - # 'control curves1': ScaffoldPackage(MeshType_1d_stickman1, { - # 'scaffoldSettings': { - # 'Coordinate dimensions': 3, - # } - # }) } @staticmethod @@ -59,10 +54,8 @@ def getName(): @classmethod def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] - # centralPathOption1 = cls.centralPathDefaultScaffoldPackages['control curves1'] options = { 'Central path': copy.deepcopy(centralPathOption), - # 'Central path1': copy.deepcopy(centralPathOption1), 'Armpit': [1.2, 0.0, 1.0], 'Head length': 1.0, 'Head number of elements': 5, @@ -114,7 +107,6 @@ def getDefaultOptions(cls, parameterSetName='Default'): def getOrderedOptionNames(): return [ 'Central path', - # 'Central path1', 'Armpit', 'Head length', 'Head number of elements', @@ -244,49 +236,47 @@ def generateBaseMesh(region, options): cx = extractPathParametersFromRegion(tmpRegion, [Node.VALUE_LABEL_VALUE])[0] def limb_angle(p1, p2): - deltacx = vector.vectorRejection(vector.addVectors([p2, p1], [1, -1]), [0.0, 1.0, 0.0]) - right_arm_angle = vector.angleBetweenVectors([p2[0], 0.0, 0.0], deltacx) - if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: - right_arm_angle = -right_arm_angle - return right_arm_angle - - # deltacx = vector.vectorRejection(vector.addVectors([cx[3], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - # right_arm_angle = vector.angleBetweenVectors([-1.0, 0.0, 0.0], deltacx) - # if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: - # right_arm_angle = -right_arm_angle - # - # deltacx = vector.vectorRejection(vector.addVectors([cx[5], cx[1]], [1, -1]), [0.0, 1.0, 0.0]) - # left_arm_angle = vector.angleBetweenVectors([1.0, 0.0, 0.0], deltacx) - # if vector.crossproduct3(deltacx, [1.0, 0.0, 0.0])[1] > 0: - # left_arm_angle = -left_arm_angle + p1p2 = vector.vectorRejection(vector.addVectors([p2, p1], [1, -1]), [0.0, 1.0, 0.0]) + angle = vector.angleBetweenVectors([p2[0], 0.0, 0.0], p1p2) + if vector.crossproduct3(p1p2, [1.0, 0.0, 0.0])[1] > 0: + angle = -angle + return angle + # get the angles from the stickman right_arm_angle = limb_angle(cx[1], cx[3]) left_arm_angle = limb_angle(cx[1], cx[5]) right_leg_angle = limb_angle(cx[2], cx[4]) left_leg_angle = limb_angle(cx[2], cx[6]) - + # create torso, head and arms trifurcation1 = TrifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, - neck_radius, shoulder_height, neck_height, right_arm_angle,left_arm_angle, - right_shoulder_length, armpit, [elementsCountAcrossMajor, elementsCountAcrossMajor, 2]) - - trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], - right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], - branch_type=BranchType.LEFT_ARM) - trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], - right_arm_length, [elementsCountAcrossMajor, elementsCountAcrossMajor, rightArmNumberOfElements], - branch_type=BranchType.RIGHT_ARM) + neck_radius, shoulder_height, neck_height, right_arm_angle, left_arm_angle, + right_shoulder_length, armpit, + [elementsCountAcrossMajor, elementsCountAcrossMajor, 2]) + + trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], right_arm_length, + [elementsCountAcrossMajor, elementsCountAcrossMajor, + rightArmNumberOfElements], + branch_type=BranchType.LEFT_ARM) + trifurcation1.create_branch_cylinder([[right_arm_radius]*2, [righ_wrist_radius]*2], right_arm_length, + [elementsCountAcrossMajor, elementsCountAcrossMajor, + rightArmNumberOfElements], + branch_type=BranchType.RIGHT_ARM) neck_cylinder = trifurcation1.create_branch_cylinder([[neck_radius2]*2, [neck_radius2]*2], neck_length, - [elementsCountAcrossMajor,elementsCountAcrossMajor, neck_number_of_elements], branch_type=BranchType.NECK) - - neck_cyliner_shield = neck_cylinder._shield - pn = PathNodes(neck_cyliner_shield, [[neck_radius2]*2, [head_radius, neck_radius2]], - head_length/head_number_of_elements, [elementsCountAcrossMajor,elementsCountAcrossMajor, 1]) + [elementsCountAcrossMajor, elementsCountAcrossMajor, + neck_number_of_elements], + branch_type=BranchType.NECK) + + # neck + neck_cylinder_shield = neck_cylinder.getShield() + pn = PathNodes(neck_cylinder_shield, [[neck_radius2]*2, [head_radius, neck_radius2]], + head_length/head_number_of_elements, [elementsCountAcrossMajor, elementsCountAcrossMajor, 1]) path_list = pn.get_path_list() path_list[1][0] = vector.addVectors( [path_list[1][0], vector.setMagnitude([0.0, -1.0, 0.0], head_length/head_number_of_elements)], [1, 1]) + # extend the neck and create the head using a cylinder with its central path cw, d1w, d2w = path_list[1][:3] d3w = path_list[1][4] for ni in range(2, head_number_of_elements + 1): @@ -297,18 +287,21 @@ def limb_angle(p1, p2): path_list.append([cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]) head_cylinder = trifurcation1.create_branch_cylinder([[neck_radius2] * 2, [head_radius, neck_radius2]], - head_length/head_number_of_elements, - [elementsCountAcrossMajor, elementsCountAcrossMajor, head_number_of_elements], path_list=path_list, - part1=neck_cyliner_shield, branch_type=4) + head_length/head_number_of_elements, + [elementsCountAcrossMajor, elementsCountAcrossMajor, + head_number_of_elements], path_list=path_list, + part1=neck_cylinder_shield, branch_type=4) cap = trifurcation1.create_branch_cap(head_cylinder, head_radius) lower_torso_cylinder = trifurcation1.create_branch_cylinder([[torso_radius]*2, lower_torso_radii], - lower_torso_length, - [elementsCountAcrossMajor,elementsCountAcrossMajor, lower_torso_number_of_elements], - part1=trifurcation1._torso_upper_part, branch_type=4, - attach_bottom=False) + lower_torso_length, + [elementsCountAcrossMajor, elementsCountAcrossMajor, + lower_torso_number_of_elements], + part1=trifurcation1._torso_upper_part, + branch_type=4, attach_bottom=False) + # create the legs bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii, right_leg_angle, left_leg_angle, part1=lower_torso_cylinder) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 030b3d2d..04052240 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -1,9 +1,10 @@ """ -Utility functions for generating a 3-D solid bifurcation. +Utility functions for generating solid bifurcation and trifurcation. """ import math from enum import Enum + from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier from opencmiss.zinc.element import Element from opencmiss.zinc.field import Field @@ -25,13 +26,23 @@ class PathNodes: + """ + Coordinates for the start and end nodes of the centralpath. + """ def __init__(self, part1, radius, length, elements_count, attach_bottom=True): + """ + Extends part1 scaffold with a cylinder with given radius and length and elements count. + :param part1: Scaffold with shield structure at its end. + :param attach_bottom: If true, the path starts from the top of the par1. Otherwise top of the + path attaches to the bottom of the part1. + """ if attach_bottom: n3 = -1 sc = 1 else: n3 = 0 sc = -1 + # get nodes parameters from part1 end. csh = part1.px[n3][elements_count[1] // 2][elements_count[0] // 2] d1sh = part1.pd2[n3][elements_count[1] // 2][elements_count[0] // 2] d2sh = part1.pd1[n3][elements_count[1] // 2][elements_count[0] // 2] @@ -56,14 +67,32 @@ def get_path_list(self): class BranchCylinder: + """ + Generates a cylinder on top of the given part. + """ def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, attach_bottom=True): + """ + Generate a cylinder to extend part1. see PathNodes class. + :param region: Zinc region + :param mesh: Zinc mesh. + :param nodes: Zinc nodeset. + :param fieldmodule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + :param path_list: node parameters on the cylinder centralpath. + :param elements_count: + :param part1: Scaffold with shield structure at its end. + :param attach_bottom: If true, the cylinder starts from the top of the par1. Otherwise top of the + cylinder attaches to the bottom of the part1 + """ if attach_bottom: n3, n3p = 0, -1 node_ranges = [1, elements_count[2]] else: n3, n3p = -1, 0 node_ranges = [0, elements_count[2] - 1] + + # generate the cylinder centralPath = ScaffoldPackage(MeshType_1d_path1, { 'scaffoldSettings': { 'Coordinate dimensions': 3, @@ -88,9 +117,11 @@ def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, ele cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, rangeOfRequiredElementsAlong=[-1, -1]) + # skip generating common nodes with the part1. cylinder.generateNodes(nodes, fieldmodule, coordinates, node_ranges) - cylinder_shield = cylinder._shield + # add the common node parameters. + cylinder_shield = cylinder.getShield() for n2 in range(elements_count[1] + 1): for n1 in range(elements_count[0] + 1): cylinder_shield.nodeId[n3][n2][n1] = part1.nodeId[n3p][n2][n1] @@ -107,7 +138,14 @@ def get_cylinder(self): class BranchCap: + """ + Create a cap to attach to the given scaffold. + """ def __init__(self, fieldmodule, coordinates, mesh, nodes, part1, radius): + """ + A hemisphere scaffold to attach to the part1 scaffold. + :param part1: Scaffold with shield structure at its end. + """ sphere_shape = SphereShape.SPHERE_SHAPE_FULL sphere_base = part1._ellipses[-1] sphere_centre = sphere_base.centre diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index 82eaeac9..db2e9f3c 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -413,6 +413,9 @@ def getElementsCountAround(self): def getElementIdentifiers(self): return self._shield.elementId + def getShield(self): + return self._shield + class Ellipse2D: """ From 4e6d0126ea6b017cc71546f2dc9f6d75f3c6fc53 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 9 Aug 2022 12:11:26 +1200 Subject: [PATCH 32/38] Minor changes --- src/scaffoldmaker/utils/bifurcation3d2.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index 04052240..b5e63822 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -230,15 +230,27 @@ class BranchType(Enum): class TrifurcationMesh: """ - Bifurction mesh generator. + Trifurcation mesh generator. """ - def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit, elements_count): """ - :param fieldModule: Zinc fieldModule to create elements in. + :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. + :param region: Zinc region + :param torso_radius: + :param left_arm_radius: + :param right_arm_radius: + :param neck_radius: + :param shoulder_height: + :param neck_height: + :param right_arm_angle: + :param left_arm_angle: + :param right_shoulder_length: + :param armpit: + :param elements_count: """ + # generate the mesh elementsCount = [2, 2, 5] self._elementsCount = elementsCount From e0b48534ef15d3353212d37db59102ea6ef22cd5 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 9 Aug 2022 13:51:39 +1200 Subject: [PATCH 33/38] Minor changes --- .../meshtype_3d_solidbifurcation2.py | 29 +- src/scaffoldmaker/utils/bifurcation3d2.py | 1486 ++++++++++------- 2 files changed, 875 insertions(+), 640 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py index 0fa8b834..318b5d1f 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py @@ -56,13 +56,14 @@ def getDefaultOptions(cls, parameterSetName='Default'): centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] options = { 'Central path': copy.deepcopy(centralPathOption), - 'Armpit': [1.2, 0.0, 1.0], - 'Head length': 1.0, + 'Armpit': [1.6, 0.0, 1.2], + 'Head length': 1.5, 'Head number of elements': 5, 'Head radius': 1.0, - 'Left arm radius': 1.0, - 'Lower torso length': 5.5, + 'Left arm radius': 0.6, + 'Lower torso length': 2.6, 'Lower torso number of elements': 4, +<<<<<<< HEAD 'Lower torso radii': [1.3, 1.0], 'Neck height': 3.6, <<<<<<< HEAD @@ -92,6 +93,21 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Shoulder height': 2.2, 'Torso radius': 1.0, >>>>>>> 5bc5787 (change the order of options) +======= + 'Lower torso radii': [1.3, 1.6], + 'Neck height': 3.3, + 'Neck length': 0.2, + 'Neck number of elements': 1, + 'Neck radius': 0.8, + 'Neck radius 2': 0.8, + 'Right arm length': 3.5, + 'Right arm number of elements': 5, + 'Right arm radius': 0.6, + 'Right shoulder length': 1.4, + 'Right wrist radius': 0.4, + 'Shoulder height': 2.1, + 'Torso radius': 1.3, +>>>>>>> 3e2b739 (Minor changes) 'Number of elements across major': 4, 'Number of elements across shell': 0, 'Number of elements across transition': 1, @@ -127,11 +143,6 @@ def getOrderedOptionNames(): 'Right wrist radius', 'Shoulder height', 'Torso radius', - 'Number of elements across major', - 'Number of elements across shell', - 'Number of elements across transition', - 'Shell element thickness proportion', - 'Pre-fit configuration', 'Refine', 'Refine number of elements across major', ] diff --git a/src/scaffoldmaker/utils/bifurcation3d2.py b/src/scaffoldmaker/utils/bifurcation3d2.py index b5e63822..b347c83b 100644 --- a/src/scaffoldmaker/utils/bifurcation3d2.py +++ b/src/scaffoldmaker/utils/bifurcation3d2.py @@ -210,7 +210,7 @@ def __init__(self, fieldmodule, coordinates, mesh, nodes, part1, radius): nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, rangeOfRequiredElements) - # generate himsphere elements. + # generate hemisphere elements. rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, @@ -233,12 +233,13 @@ class TrifurcationMesh: Trifurcation mesh generator. """ def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, - shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit, elements_count): + shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit, + elements_count): """ :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :param region: Zinc region - :param torso_radius: + :param torso_radius: upper torso radius :param left_arm_radius: :param right_arm_radius: :param neck_radius: @@ -283,18 +284,10 @@ def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radi def createTrifurcationMesh3d(self, fieldmodule, coordinates): """ Create a trifurcation. - :param fieldModule: Zinc fieldModule to create elements in. + :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :return: Final values of nextNodeIdentifier, nextElementIdentifier. """ - # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' - # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' - # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ - # ' is not an even number' - # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' - # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, - # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ - # 'createCylinderMesh3d: Invalid cylinder mode.' nodes = self._nodes mesh = self._mesh base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() @@ -342,12 +335,24 @@ def createTrifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, neck_part) self._neck_part = neck_part - box_part = BoxPart([elementsCount[0] - 2, elementsCount[1], elementsCount[0] - 2], torso_upper_part, shoulder_part, shoulder_part_left, neck_part) + box_part = BoxPart([elementsCount[0] - 2, elementsCount[1], elementsCount[0] - 2], torso_upper_part, + shoulder_part, shoulder_part_left, neck_part) self.generateNodes(nodes, fieldmodule, coordinates, box_part) self.generateElements(mesh, fieldmodule, coordinates, box_part) def create_branch_cylinder(self, radius, length, number_of_elements, path_list=None, part1=None, attach_bottom=True, branch_type=BranchType.LEFT_ARM): + """ + Creates a cylinder attached to the part1 + :param radius: + :param length: + :param number_of_elements: + :param path_list: + :param part1: + :param attach_bottom: + :param branch_type: + :return: + """ if branch_type == BranchType.LEFT_ARM: part1 = self._shoulder_part elif branch_type == BranchType.RIGHT_ARM: @@ -365,6 +370,12 @@ def create_branch_cylinder(self, radius, length, number_of_elements, path_list=N return cylinder def create_branch_cap(self, part1, radius): + """ + Creates a cap attached to the part1 + :param part1: + :param radius: + :return: + """ cap = BranchCap(self._fieldmodule, self._coordinates, self._mesh, self._nodes, part1, radius) return cap @@ -376,7 +387,7 @@ def smooth_all_derivatives(self): def _get_node_params(self): """ - + Get node parameter for the landmarks :return: """ class CylinderCurves: @@ -444,10 +455,16 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): cev = vector.rotateVectorAroundVector(cv, kv, self.left_arm_angle) cevunit = vector.normalise(cev) ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) - x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius)], [1, 1]) + x_shoulder_end_curve1 = vector.addVectors( + [ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius)], [1, 1]) x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) +<<<<<<< HEAD d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius/self._elementsCount[1])]*2 >>>>>>> 5931d2a (Separate arms from upper torso) +======= + d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), + self.left_arm_radius/self._elementsCount[1])]*2 +>>>>>>> 3e2b739 (Minor changes) d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 bc = EllipseCurves([[0.75, 0.0, self.shoulder_height], armpit], @@ -464,9 +481,11 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): cv = [-self.right_shoulder_length, 0.0, 0.0] cev = vector.rotateVectorAroundVector(cv, kv, -self.right_arm_angle) ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) - x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius)], [1, 1]) + x_shoulder_end_curve2 = vector.addVectors( + [ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius)], [1, 1]) x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) - d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), + self.right_arm_radius/self._elementsCount[1])]*2 d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0]]*2 bc = EllipseCurves([[-0.75, 0.0, self.shoulder_height], [-0.75, 1.0, self.shoulder_height]], @@ -498,10 +517,10 @@ def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): """ - + Attach torso to shoulder :param joining_torso: - :param shoulder_part: - :param bottom_part: + :param shoulder_joint: + :param bottom_joint: :return: """ for n2 in range(joining_torso._elementsCount[1] + 1): @@ -525,16 +544,20 @@ def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] - def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): + def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, + cidxs, bidx): """ :param shoulder_connecting_to_box: :param joining_box: - :param shoulder_part: + :param cylinder_part: + :param cidxs: + :param bidx: :return: """ for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): - for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): + for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, + shoulder_connecting_to_box._elementsCount[0] + 1): shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] @@ -572,7 +595,7 @@ def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): """ :param shoulder_part: - :param bottom_part: + :param c: :return: """ def condition(n2, n1): @@ -598,10 +621,6 @@ def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): :return: """ def condition(n2, n1): - # if c: - # n2, n1 = n1, n2 - # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ - # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) if c: return n2 == 0 or n2 == 1 else: @@ -633,6 +652,8 @@ def index(n2, n1): def copyBaseLeg2Trifurcation(self, baseleg, idx): """ + :param baseleg: + :param idx: :return: """ for n3 in range(self._elementsCount[2]//2 + 1): @@ -647,18 +668,17 @@ def copyBaseLeg2Trifurcation(self, baseleg, idx): self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] if idx == 2 and n3 == 0: - if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and + n1 == 1): self.px[n3s][n2][n1] = None self.pd1[n3s][n2][n1] = None self.pd2[n3s][n2][n1] = None self.pd3[n3s][n2][n1] = None - def remove_duplicate_nodes_from_neck(self, neck_part): """ - :param shoulder_part: - :param bottom_part: + :param neck_part: :return: """ for n2 in range(neck_part._elementsCount[1] + 1): @@ -672,8 +692,9 @@ def remove_duplicate_nodes_from_neck(self, neck_part): def join_neck_to_torso(self, neck_part, shoulder_part, shoulder_part_left): """ + :param neck_part: :param shoulder_part: - :param bottom_part: + :param shoulder_part_left: :return: """ for n2 in range(neck_part._elementsCount[1] + 1): @@ -726,7 +747,8 @@ def generateElements(self, mesh, fieldModule, coordinates, part_structure): """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier - elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, + []) self._endElementIdentifier = elementIdentifier def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): @@ -751,10 +773,14 @@ def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, p node = nodes.createNode(nodeIdentifier, nodetemplate) part_structure.nodeId[n3][n2][n1] = nodeIdentifier cache.setNode(node) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, + part_structure.px[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, + part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, + part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, + part_structure.pd3[n3][n2][n1]) nodeIdentifier += 1 return nodeIdentifier @@ -797,10 +823,10 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif for e1 in range(part_structure._elementsCount[0]): eft1 = eft scalefactors = None - nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], - part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], - part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], - part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + nids = [part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1]] if isinstance(part_structure, BoxPart): if e3 == 0: @@ -958,13 +984,17 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e2 == e2a: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) if e2 == e2z: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif e3 == part_structure._elementsCount[2] - 1: if e1 == 0: eft1 = tricubichermite.createEftNoCrossDerivatives() @@ -1124,13 +1154,17 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e2 == e2a: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) else: eft1 = tricubichermite.createEftNoCrossDerivatives() @@ -1138,157 +1172,125 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e2 == e2a: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) else: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) elif e1 == e1z: if e2 == e2a: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) elif e2 == e2z: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) else: if e2 == e2a: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) elif e2 == e2z: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - - - # if e2 == e2a: - # if e3 == 0 and e1 == 0: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # elif e3 == 0 and e1 == e1z: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - # elif e3 == part_structure._elementsCount[2] and e1 == 0: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # elif e3 == part_structure._elementsCount[2] and e1 == e1z: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # elif e2 == e2z: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # else: - # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif part_structure._neck and e3 == 0: if (e2 < e2b) or (e2 > e2y): @@ -1301,49 +1303,75 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] if e1 == e1a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) elif e1 == e1y: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, []), + (Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1]), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1]), + (Node.VALUE_LABEL_D_DS1, [])]) elif e1b < e1 < e1y: remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + + [(Node.VALUE_LABEL_D_DS1, [])]) else: remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [1])]) # if (e1 == e1b) or (e1 == e1y): if e1 == e1b: # map bottom triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) if e3 == 0: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) else: - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2z: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -1355,37 +1383,71 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if (e1 == e1b) or (e1 == e1y): # map top triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif e1 == e1y: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) elif e1b < e1 < e1y: - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): @@ -1405,107 +1467,181 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif nids[0] = part_structure.nodeId[e3][e2a][e1b] nids[2] = part_structure.nodeId[e3+1][e2a][e1b] if e3 == 0: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] if e3 == 0: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [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] ) ]) + remapEftNodeValueLabel(eft1, [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 e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.nodeId[e3+1][e2a][e1z] setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) if e3 == 0: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) elif e2 == e2y: nids[5] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) if e3 == 0: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) elif e1 == e1b: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] if e3 == 0: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) if e2 == e2y: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) elif e1 == e1y: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) if e2 == e2y: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif e2b < e2 < e2y: if e1 == e1a: @@ -1516,62 +1652,75 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) - - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS1, []), - # (Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) elif e1 == e1b: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) elif e1 == e1y: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - - # else: - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) else: if e1 < e1a: - nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] elif e1 == e1a: # map left column elements eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) + scalefactors = [-1.0] + 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])]) else: if (e2 < e2b) or (e2 > e2y): @@ -1579,11 +1728,23 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif continue # no element due to triple point closure if (e2 < e2a) or (e2 > e2z): if e2 < e2a: - nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], - part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + nids = [part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1]] elif e2 > e2z: - nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], - part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + nids = [part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1]] elif (e2 == e2a) or (e2 == e2z): # bottom and top row elements if e2 == e2a: @@ -1595,7 +1756,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if part_structure._shoulder: if e3 == 0 and e1 == e1b: remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) @@ -1610,45 +1772,72 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [])]) if e3 == 0: if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) if (e1 == e1b) or (e1 == e1y): # map bottom triple point element if e1 == e1b: # if e3 != 2: - # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) if part_structure._shoulder_left: if e3 == 0: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: if part_structure._shoulder: if e3 == 0: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: if part_structure._shoulder_left: if e3 == 0: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) else: - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) else: remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), @@ -1659,35 +1848,59 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif scalefactors = [-1.0] if isinstance(part_structure, BaseLeg): if part_structure._shoulder and e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) if (e1 == e1b) or (e1 == e1y): # map top triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) if e3 == 0: if part_structure._shoulder: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) if part_structure._shoulder: if e3 == 0: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): if e1 < e1a: e2r = e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], - part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + nids = [part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3+1][e2c][e1+1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1b]] if e2 == e2y: e2r = 2*part_structure._elementsCount[1] - e1-1 - nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], - part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + nids = [part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3][e2y][e1+1], + part_structure.nodeId[e3+1][e2r][e1b], + part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3][e2y][e1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3+1][e2y][e1]] elif e1 == e1a: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -1706,51 +1919,87 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if part_structure._shoulder_left: if e3 == 0: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) else: - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: tripleN = [5, 7] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] tripleN = [6, 8] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - 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] ) ]) + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + 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])]) if e3 == 0: if part_structure._shoulder: - remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.nodeId[e3+1][e2a][e1z] setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] + scalefactors = [-1.0] if part_structure._shoulder_left: if e3 == 0: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + 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] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif e1 > e1z: e2r = part_structure._elementsCount[0] - e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], - part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + nids = [part_structure.nodeId[e3][e2r][e1z], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1z], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], + part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3+1][e2r-1][e1z], + part_structure.nodeId[e3+1][e2c][e1+1]] elif e2 == e2y: e2r = e2z+e1-e1z nids[1] = part_structure.nodeId[e3][e2r][e1z] @@ -1762,14 +2011,19 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif eft1 = tricubichermite.createEftNoCrossDerivatives() if part_structure._shoulder_left: if e3 == 0: - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) if part_structure._shoulder: if e3 == 0: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) if e2 == e2y: if part_structure._shoulder: @@ -1777,56 +2031,70 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e3 == 0: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1,2], Node.VALUE_LABEL_D_DS2, + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) elif e1 == e1y: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() if part_structure._shoulder_left: if e3 == 0: - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) else: if part_structure._shoulder_left: eft1 = tricubichermite.createEftNoCrossDerivatives() if e3 == 0 and e2 <= e2b: - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - - + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) else: if e1 < e1a: - nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] elif e1 == e1a: # map left column elements eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) + scalefactors = [-1.0] + 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])]) if e3 == 0 and part_structure._shoulder: remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e1 == e1b: eft1 = tricubichermite.createEftNoCrossDerivatives() if e3 == 0 and part_structure._shoulder: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) if not all(nids): continue @@ -1841,7 +2109,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif result3 = element.setScaleFactors(eft1, scalefactors) else: result3 = 7 - #print('create element shield', elementIdentifier, result2, result3, nids) part_structure.elementId[e3][e2][e1] = elementIdentifier elementIdentifier += 1 @@ -1866,23 +2133,28 @@ def __init__(self, elementsCount, cyl_curves, shoulder_right=False, shoulder_lef >>>>>>> 9619665 (Modify axes and clean the code and make some classes) """ - :param fieldmodule: - :param coordinates: - :param mesh: - :param nodes: + :param elementsCount: + :param cyl_curves: + :param shoulder_right: + :param shoulder_left: """ - # elementsCount = [4, 4, 2] self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] self._shoulder = False self._shoulder_left = False self._neck = False - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] self.generateBaseLeg(cyl_curves.curves) bc = cyl_curves.curves[0] @@ -2122,7 +2394,8 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) shield = ellipse.getShield() ellipse.generateBase1DMesh(0) @@ -2144,7 +2417,8 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): # ellipse.px[0][self._elementsCount[0]][2] x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) - delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] + for c in range(3)] normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) delta_p_normalmag = vector.dotproduct(delta_p, normal) @@ -2242,7 +2516,7 @@ def __init__(self, fieldModule, coordinates, region, centre, radii, right_leg_an def createBifurcationMesh3d(self, fieldmodule, coordinates): """ Create a trifurcation. - :param fieldModule: Zinc fieldModule to create elements in. + :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :return: Final values of nextNodeIdentifier, nextElementIdentifier. """ @@ -2257,7 +2531,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) mesh = fieldmodule.findMeshByDimension(3) - elementsCountAcrossShell = 0 elementsCountAcrossTransition = 1 shellProportion = 1.0 @@ -2273,22 +2546,20 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): radius3 = 0.8 majorAxis = vector.scaleVector(ya, radius2) minorAxis = vector.scaleVector(xa, -radius1) - centre1 = vector.addVectors([self._centre, vector.setMagnitude(za, -0.0)] , [1, 1]) - + centre1 = vector.addVectors([self._centre, vector.setMagnitude(za, -0.0)], [1, 1]) ellipse1 = Ellipse2D(centre1, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - - # shield = ellipse1.getShield() - # self.generateNodes(nodes, fieldmodule, coordinates, shield) + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) majorAxis = vector.scaleVector(ya, radius2) minorAxis = vector.scaleVector(za, -radius3) ellipse2 = Ellipse2D(centre1, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) elementsCount = [ellipse2.elementsCountAcrossMinor, ellipse2.elementsCountAcrossMajor, 1] @@ -2298,9 +2569,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): if n1 <= elementsCount[1]//2: shield.px[0][n2][n1] = None - # self.generateNodes(nodes, fieldmodule, coordinates, shield) - - radius1 = 0.8 radius2 = 0.8 hip_length = 1.6 @@ -2320,16 +2588,16 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) ellipse3 = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - # shield = ellipse3.getShield() - # self.generateNodes(nodes, fieldmodule, coordinates, shield) + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) hip_left = Hip(elementsCount, 'left') pr = [hip_left.nodeId, hip_left.px, hip_left.pd1, hip_left.pd2, hip_left.pd3] p1 = [ellipse1.nodeId[0], ellipse1.px, ellipse1.pd1, ellipse1.pd2, ellipse1.pd3] - p1v2 = [self._part1._shield.nodeId[0], self._part1._shield.px[0], self._part1._shield.pd1[0], self._part1._shield.pd2[0], self._part1._shield.pd3[0]] + p1v2 = [self._part1._shield.nodeId[0], self._part1._shield.px[0], + self._part1._shield.pd1[0], self._part1._shield.pd2[0], self._part1._shield.pd3[0]] p2 = [ellipse2.nodeId[0], ellipse2.px, ellipse2.pd1, ellipse2.pd2, ellipse2.pd3] p3 = [ellipse3.nodeId[0], ellipse3.px, ellipse3.pd1, ellipse3.pd2, ellipse3.pd3] for n3 in range(elementsCount[2] + 1): @@ -2357,20 +2625,20 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): self.generateElements(mesh, fieldmodule, coordinates, hip_left) x_hip_joint = vector.addVectors([centre1, - vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -math.pi/4), + vector.setMagnitude(vector.rotateVectorAroundVector( + vector.scaleVector(xa, -1), kv, -math.pi/4), hip_distance)], [1, 1]) - Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -self.right_leg_angle), hip_length) + Lv = vector.setMagnitude(vector.rotateVectorAroundVector(vector.scaleVector(xa, -1), kv, -self.right_leg_angle), + hip_length) centre = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) # centre = vector.addVectors([centre1, Lv], [1, 1]) minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) ellipse4 = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - - # shield = ellipse4.getShield() - # self.generateNodes(nodes, fieldmodule, coordinates, shield) + elementsCountAcrossShell, elementsCountAcrossTransition, + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) hip_right = Hip(elementsCount, 'right') @@ -2403,7 +2671,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pl[i][n3][n2][n1] = p1v2[i][n2][n1] self.generateElements(mesh, fieldmodule, coordinates, hip_right) - pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, @@ -2415,7 +2682,6 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, path_list, [4, 4, 7], hip_right, attach_bottom=False) cylinder = bc.get_cylinder() - a=1 def generateNodes(self, nodes, fieldModule, coordinates, part_structure): """ @@ -2444,17 +2710,21 @@ def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, p nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) cache = fieldmodule.createFieldcache() - for n3 in range(1 + 1): # TODO should change to number of elements alogn, major, minor. + for n3 in range(1 + 1): # TODO should change to number of elements along, major, minor. for n2 in range(4 + 1): for n1 in range(4 + 1): if part_structure.px[n3][n2][n1]: node = nodes.createNode(nodeIdentifier, nodetemplate) part_structure.nodeId[n3][n2][n1] = nodeIdentifier cache.setNode(node) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, + part_structure.px[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, + part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, + part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, + part_structure.pd3[n3][n2][n1]) nodeIdentifier += 1 return nodeIdentifier @@ -2468,7 +2738,8 @@ def generateElements(self, mesh, fieldModule, coordinates, part_structure): """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier - elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, + []) self._endElementIdentifier = elementIdentifier def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, meshGroups=[]): @@ -2509,38 +2780,33 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif for e1 in range(part_structure._elementsCount[0]): eft1 = eft scalefactors = None - nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], - part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], - part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], - part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] + nids = [part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1]] if (e2 < e2b) or (e2 > e2y): if (e1 < e1b) or (e1 > e1y): continue # no element due to triple point closure if (e2 < e2a) or (e2 > e2z): if e2 < e2a: - nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], - part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] elif e2 > e2z: - nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], - part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] elif (e2 == e2a) or (e2 == e2z): # bottom and top row elements if e2 == e2a: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - # if not part_structure._shoulder_left: - # if isinstance(part_structure, BaseLeg): - # if part_structure._shoulder: - # if e3 == 0 and e1 == e1b: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), - # (Node.VALUE_LABEL_D_DS3, [1])]) if part_structure._side == 'left': - # if e3,e2,e1 = 0, 0, 2 + # if e3,e2,e1 = 0, 0, 2 if e1 == e1y: remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) @@ -2567,7 +2833,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) else: @@ -2576,54 +2843,14 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - - # else: - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) - # if e3 == 0: - # if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): - # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [])]) if (e1 == e1b) or (e1 == e1y): - # # map bottom triple point element + # map bottom triple point element if e1 == e1b: - # if e3 != 2: - # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - # if part_structure._shoulder_left: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # else: - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # else: - # if part_structure._shoulder: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # else: - # remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # else: - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: - # if part_structure._shoulder_left: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - # else: - # remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) @@ -2633,12 +2860,15 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif scalefactors = [-1.0] if isinstance(part_structure, BaseLeg): if part_structure._shoulder and e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) # TODO if e3 == -1 - remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) if part_structure._side == 'left': if e1 == e1y: remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, @@ -2653,21 +2883,11 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) elif part_structure._side == 'right': - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS3, [1])]) if e1 == e1b: remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D2_DS1DS2, [])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, @@ -2675,7 +2895,8 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS1, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) else: @@ -2683,36 +2904,43 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) if (e1 == e1b) or (e1 == e1y): # map top triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # if e3 == 0: - # # if part_structure._shoulder: - # # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # if part_structure._shoulder: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) else: - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): if e1 < e1a: e2r = e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], - part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + nids = [part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3+1][e2c][e1+1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1b]] if e2 == e2y: e2r = 2*part_structure._elementsCount[1] - e1-1 - nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], - part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + nids = [part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3][e2y][e1+1], + part_structure.nodeId[e3+1][e2r][e1b], + part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3][e2y][e1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3+1][e2y][e1]] elif e1 == e1a: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -2728,31 +2956,27 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: nids[0] = part_structure.nodeId[e3][e2a][e1b] nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - - # if part_structure._shoulder_left: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - # else: - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # else: tripleN = [5, 7] if part_structure._side == 'left' else [5] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] tripleN = [6, 8] if part_structure._side == 'left' else [6] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) if part_structure._side == 'right': - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) if e2 == e2b: remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2y: @@ -2761,45 +2985,37 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [1])]) + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) elif part_structure._side == 'left': - # remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [1]), - # (Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [1, 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] ) ]) - # if e3 == 0: - # if part_structure._shoulder: - # remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.nodeId[e3+1][e2a][e1z] setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - # if part_structure._shoulder_left: - # if e3 == 0: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - # else: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - # else: - remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) if part_structure._side == 'left': - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2y: nids[5] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) # if e3,e2,e1 = 0 2 3 if part_structure._side == 'left': setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, @@ -2807,8 +3023,14 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 > e1z: e2r = part_structure._elementsCount[0] - e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], - part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + nids = [part_structure.nodeId[e3][e2r][e1z], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1z], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], + part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3+1][e2r-1][e1z], + part_structure.nodeId[e3+1][e2c][e1+1]] elif e2 == e2y: e2r = e2z+e1-e1z nids[1] = part_structure.nodeId[e3][e2r][e1z] @@ -2839,7 +3061,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS3, [1])]) - elif e1 == e1y: if e2 == e2b or e2 == e2y: eft1 = tricubichermite.createEftNoCrossDerivatives() @@ -2851,35 +3072,25 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [1])]) - - - # if part_structure._shoulder_left: - # if e3 == 0: - # # remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - - # else: - # if part_structure._shoulder_left: - # eft1 = tricubichermite.createEftNoCrossDerivatives() - # if e3 == 0 and e2 <= e2b: - # # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [])]) - # remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - - - else: if e1 < e1a: - nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] elif e1 == e1a: # map left column elements eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) + scalefactors = [-1.0] + 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])]) if e3 == 0 and part_structure._shoulder: remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) @@ -2889,12 +3100,14 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif if e3 == 0 and part_structure._shoulder: setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) - - + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) if not all(nids): continue @@ -2909,7 +3122,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif result3 = element.setScaleFactors(eft1, scalefactors) else: result3 = 7 - #print('create element shield', elementIdentifier, result2, result3, nids) part_structure.elementId[e3][e2][e1] = elementIdentifier elementIdentifier += 1 @@ -2926,15 +3138,20 @@ def __init__(self, elementsCount, side): elementsCount = elementsCount - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - - + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] class BoxPart: @@ -2948,13 +3165,20 @@ def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): # elementsCount = [4, 6, 4] elementsCount = elementsCount - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] torso_elements_count = [len(torso.px[0][0])-1, len(torso.px[0])-1, len(torso.px)-1] p = [self.nodeId, self._px, self.pd1, self.pd2, self.pd3] From d48f1e1fc43f7b1df82f690f2b08521c3e542904 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 9 Aug 2022 14:06:39 +1200 Subject: [PATCH 34/38] rename filenames --- .../meshtype_3d_solidbifurcation1.py | 196 - ...urcation2.py => meshtype_3d_wholebody2.py} | 6 +- src/scaffoldmaker/scaffolds.py | 10 +- src/scaffoldmaker/utils/bifurcation3d.py | 3173 +++++++++++++---- src/scaffoldmaker/utils/bifurcation3d3.py | 1619 --------- 5 files changed, 2542 insertions(+), 2462 deletions(-) delete mode 100644 src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py rename src/scaffoldmaker/meshtypes/{meshtype_3d_solidbifurcation2.py => meshtype_3d_wholebody2.py} (98%) delete mode 100644 src/scaffoldmaker/utils/bifurcation3d3.py diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py deleted file mode 100644 index c63c5e3d..00000000 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation1.py +++ /dev/null @@ -1,196 +0,0 @@ -""" -Generates a solid cylinder using a ShieldMesh of all cube elements, - with variable numbers of elements in major, minor, shell and axial directions. -""" - -from __future__ import division -import math -import copy -from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates -from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base -from scaffoldmaker.utils.meshrefinement import MeshRefinement -from scaffoldmaker.utils.cylindermesh import CylinderMesh, CylinderShape, CylinderEnds, CylinderCentralPath -from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues -from scaffoldmaker.scaffoldpackage import ScaffoldPackage -from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 -from opencmiss.zinc.node import Node -from scaffoldmaker.utils.bifurcation3d import BifurcationMesh - - -class MeshType_3d_solidbifurcation1(Scaffold_base): - """ -Generates a solid cylinder using a ShieldMesh of all cube elements, -with variable numbers of elements in major, minor, shell and axial directions. - """ - centralPathDefaultScaffoldPackages = { - 'Cylinder 1': ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 3.0, - 'Number of elements': 3 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - [[0.0, 0.0, 2.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] - ]) - }) - } - - @staticmethod - def getName(): - return '3D Solid Bifurcation 1' - - @classmethod - def getDefaultOptions(cls, parameterSetName='Default'): - centralPathOption = cls.centralPathDefaultScaffoldPackages['Cylinder 1'] - options = { - 'Central path': copy.deepcopy(centralPathOption), - 'Number of elements across major': 4, - 'Number of elements across minor': 4, - 'Number of elements across shell': 0, - 'Number of elements across transition': 1, - 'Number of elements along': 1, - 'Shell element thickness proportion': 1.0, - 'Lower half': False, - 'Use cross derivatives': False, - 'Refine': False, - 'Refine number of elements across major': 1, - 'Refine number of elements along': 1 - } - return options - - @staticmethod - def getOrderedOptionNames(): - return [ - 'Central path', - 'Number of elements across major', - 'Number of elements across minor', - 'Number of elements across shell', - 'Number of elements across transition', - 'Number of elements along', - 'Shell element thickness proportion', - 'Lower half', - 'Refine', - 'Refine number of elements across major', - 'Refine number of elements along' - ] - - @classmethod - def getOptionValidScaffoldTypes(cls, optionName): - if optionName == 'Central path': - return [MeshType_1d_path1] - return [] - - @classmethod - def getOptionScaffoldTypeParameterSetNames(cls, optionName, scaffoldType): - if optionName == 'Central path': - return list(cls.centralPathDefaultScaffoldPackages.keys()) - assert scaffoldType in cls.getOptionValidScaffoldTypes(optionName), \ - cls.__name__ + '.getOptionScaffoldTypeParameterSetNames. ' + \ - 'Invalid option \'' + optionName + '\' scaffold type ' + scaffoldType.getName() - return scaffoldType.getParameterSetNames() - - @classmethod - def getOptionScaffoldPackage(cls, optionName, scaffoldType, parameterSetName=None): - ''' - :param parameterSetName: Name of valid parameter set for option Scaffold, or None for default. - :return: ScaffoldPackage. - ''' - if parameterSetName: - assert parameterSetName in cls.getOptionScaffoldTypeParameterSetNames(optionName, scaffoldType), \ - 'Invalid parameter set ' + str(parameterSetName) + ' for scaffold ' + str(scaffoldType.getName()) + \ - ' in option ' + str(optionName) + ' of scaffold ' + cls.getName() - if optionName == 'Central path': - if not parameterSetName: - parameterSetName = list(cls.centralPathDefaultScaffoldPackages.keys())[0] - return copy.deepcopy(cls.centralPathDefaultScaffoldPackages[parameterSetName]) - assert False, cls.__name__ + '.getOptionScaffoldPackage: Option ' + optionName + ' is not a scaffold' - - @classmethod - def checkOptions(cls, options): - if not options['Central path'].getScaffoldType() in cls.getOptionValidScaffoldTypes('Central path'): - options['Central path'] = cls.getOptionScaffoldPackage('Central path', MeshType_1d_path1) - dependentChanges = False - - if options['Number of elements across major'] < 4: - options['Number of elements across major'] = 4 - if options['Number of elements across major'] % 2: - options['Number of elements across major'] += 1 - - if options['Number of elements across minor'] < 4: - options['Number of elements across minor'] = 4 - if options['Number of elements across minor'] % 2: - options['Number of elements across minor'] += 1 - if options['Number of elements along'] < 1: - options['Number of elements along'] = 1 - if options['Number of elements across transition'] < 1: - options['Number of elements across transition'] = 1 - Rcrit = min(options['Number of elements across major']-4, options['Number of elements across minor']-4)//2 - if options['Number of elements across shell'] + options['Number of elements across transition'] - 1 > Rcrit: - dependentChanges = True - options['Number of elements across shell'] = Rcrit - options['Number of elements across transition'] = 1 - - if options['Shell element thickness proportion'] < 0.15: - options['Shell element thickness proportion'] = 1.0 - - return dependentChanges - - @staticmethod - def generateBaseMesh(region, options): - """ - Generate the base tricubic Hermite mesh. See also generateMesh(). - :param region: Zinc region to define model in. Must be empty. - :param options: Dict containing options. See getDefaultOptions(). - :return: None - """ - - 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'] - elementsCountAlong = options['Number of elements along'] - shellProportion = options['Shell element thickness proportion'] - useCrossDerivatives = options['Use cross derivatives'] - - fm = region.getFieldmodule() - coordinates = findOrCreateFieldCoordinates(fm) - - # cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) - # - # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF - # - # base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, - # elementsCountAcrossTransition, - # shellProportion, - # [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - # cylinderCentralPath.minorRadii[0]) - # cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, - # cylinderShape=cylinderShape, - # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - bifurcation1 = BifurcationMesh(fm, coordinates, region) - - annotationGroup = [] - return annotationGroup - - @classmethod - def refineMesh(cls, meshRefinement, options): - """ - Refine source mesh into separate region, with change of basis. - :param meshRefinement: MeshRefinement, which knows source and target region. - :param options: Dict containing options. See getDefaultOptions(). - """ - assert isinstance(meshRefinement, MeshRefinement) - refineElementsCountAcrossMajor = options['Refine number of elements across major'] - refineElementsCountAlong = options['Refine number of elements along'] - meshRefinement.refineAllElementsCubeStandard3d(refineElementsCountAcrossMajor, refineElementsCountAlong, refineElementsCountAcrossMajor) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py similarity index 98% rename from src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py rename to src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py index 318b5d1f..a6e9a80b 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidbifurcation2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py @@ -13,11 +13,11 @@ from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base from scaffoldmaker.scaffoldpackage import ScaffoldPackage from scaffoldmaker.utils import vector -from scaffoldmaker.utils.bifurcation3d2 import TrifurcationMesh, BranchType, PathNodes, BifurcationMesh +from scaffoldmaker.utils.bifurcation3d import TrifurcationMesh, BranchType, PathNodes, BifurcationMesh from scaffoldmaker.utils.meshrefinement import MeshRefinement -class MeshType_3d_solidbifurcation2(Scaffold_base): +class MeshType_3d_wholebody2(Scaffold_base): """ Generates a whole body scaffold using a mesh of all cube elements, with features to control arms, torso, neck and head. @@ -49,7 +49,7 @@ class MeshType_3d_solidbifurcation2(Scaffold_base): @staticmethod def getName(): - return '3D Solid Bifurcation 2' + return '3D Whole Body 2' @classmethod def getDefaultOptions(cls, parameterSetName='Default'): diff --git a/src/scaffoldmaker/scaffolds.py b/src/scaffoldmaker/scaffolds.py index 8359eed8..892e7620 100644 --- a/src/scaffoldmaker/scaffolds.py +++ b/src/scaffoldmaker/scaffolds.py @@ -40,10 +40,13 @@ from scaffoldmaker.meshtypes.meshtype_3d_smallintestine1 import MeshType_3d_smallintestine1 <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation1 import MeshType_3d_solidbifurcation1 from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation2 import MeshType_3d_solidbifurcation2 >>>>>>> cfec53f (copied to 2nd one) +======= +>>>>>>> 85d7286 (rename filenames) from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere2 import MeshType_3d_solidsphere2 @@ -60,6 +63,7 @@ from scaffoldmaker.meshtypes.meshtype_3d_tube1 import MeshType_3d_tube1 from scaffoldmaker.meshtypes.meshtype_3d_tubeseptum1 import MeshType_3d_tubeseptum1 from scaffoldmaker.meshtypes.meshtype_3d_wholebody1 import MeshType_3d_wholebody1 +from scaffoldmaker.meshtypes.meshtype_3d_wholebody2 import MeshType_3d_wholebody2 from scaffoldmaker.scaffoldpackage import ScaffoldPackage @@ -104,10 +108,13 @@ def __init__(self): MeshType_3d_smallintestine1, <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= MeshType_3d_solidbifurcation1, MeshType_3d_solidbifurcation2, >>>>>>> cfec53f (copied to 2nd one) +======= +>>>>>>> 85d7286 (rename filenames) MeshType_3d_solidcylinder1, MeshType_3d_solidsphere1, MeshType_3d_solidsphere2, @@ -123,7 +130,8 @@ def __init__(self): MeshType_3d_stomachhuman1, MeshType_3d_tube1, MeshType_3d_tubeseptum1, - MeshType_3d_wholebody1 + MeshType_3d_wholebody1, + MeshType_3d_wholebody2, ] def findScaffoldTypeByName(self, name): diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index 7be38849..81e881cf 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -1,339 +1,476 @@ """ -Utility functions for generating a 3-D solid bifurcation. +Utility functions for generating solid bifurcation and trifurcation. """ -import copy -from enum import Enum -from scaffoldmaker.utils import vector, geometry import math -from opencmiss.zinc.field import Field + +from enum import Enum + from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier -from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode -from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ - smoothCubicHermiteDerivativesLine, interpolateSampleLinear -from opencmiss.zinc.node import Node -from scaffoldmaker.utils.mirror import Mirror -from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion -from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh -from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite -from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds from opencmiss.zinc.element import Element -from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from opencmiss.zinc.field import Field +from opencmiss.zinc.node import Node from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 +from scaffoldmaker.scaffoldpackage import ScaffoldPackage +from scaffoldmaker.utils import vector, geometry +from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds,\ + CylinderMesh +from scaffoldmaker.utils.derivativemoothing import DerivativeSmoothing +from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds +from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite +from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ + smoothCubicHermiteDerivativesLine +from scaffoldmaker.utils.mirror import Mirror +from scaffoldmaker.utils.shieldmesh import ShieldMesh3D +from scaffoldmaker.utils.spheremesh import SphereMesh, SphereShape from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues -class BifurcationMesh: +class PathNodes: """ - Bifurction mesh generator. + Coordinates for the start and end nodes of the centralpath. + """ + def __init__(self, part1, radius, length, elements_count, attach_bottom=True): + """ + Extends part1 scaffold with a cylinder with given radius and length and elements count. + :param part1: Scaffold with shield structure at its end. + :param attach_bottom: If true, the path starts from the top of the par1. Otherwise top of the + path attaches to the bottom of the part1. + """ + if attach_bottom: + n3 = -1 + sc = 1 + else: + n3 = 0 + sc = -1 + # get nodes parameters from part1 end. + csh = part1.px[n3][elements_count[1] // 2][elements_count[0] // 2] + d1sh = part1.pd2[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = part1.pd1[n3][elements_count[1] // 2][elements_count[0] // 2] + d3sh = part1.pd3[n3][elements_count[1] // 2][elements_count[0] // 2] + d2sh = vector.setMagnitude(d2sh, -radius[0][0]) + d3sh = vector.setMagnitude(d3sh, radius[0][1]) + cw = vector.addVectors([csh, vector.setMagnitude(d1sh, sc * length)], [1, 1]) + d1w = vector.setMagnitude(d1sh, length / elements_count[2]) + d2w = vector.setMagnitude(d2sh, radius[1][0]) + d3w = vector.setMagnitude(d3sh, radius[1][1]) + + if attach_bottom: + path_list = [[csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]], + [cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]]] + else: + path_list = [[cw, d1w, d2w, [0.0, 0.0, 0.0], d3w, [0.0, 0.0, 0.0]], + [csh, d1sh, d2sh, [0.0, 0.0, 0.0], d3sh, [0.0, 0.0, 0.0]]] + self.path_list = path_list + + def get_path_list(self): + return self.path_list + + +class BranchCylinder: + """ + Generates a cylinder on top of the given part. """ + def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, + attach_bottom=True): + """ + Generate a cylinder to extend part1. see PathNodes class. + :param region: Zinc region + :param mesh: Zinc mesh. + :param nodes: Zinc nodeset. + :param fieldmodule: Zinc fieldModule to create elements in. + :param coordinates: Coordinate field to define. + :param path_list: node parameters on the cylinder centralpath. + :param elements_count: + :param part1: Scaffold with shield structure at its end. + :param attach_bottom: If true, the cylinder starts from the top of the par1. Otherwise top of the + cylinder attaches to the bottom of the part1 + """ + if attach_bottom: + n3, n3p = 0, -1 + node_ranges = [1, elements_count[2]] + else: + n3, n3p = -1, 0 + node_ranges = [0, elements_count[2] - 1] + + # generate the cylinder + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': len(path_list) - 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, + Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], + path_list) + }) + cylinderCentralPath = CylinderCentralPath(region, centralPath, elements_count[2]) + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL + centre = path_list[0][0] + base = CylinderEnds(elements_count[1], elements_count[0], 0, 1, 1.0, + centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], + cylinderCentralPath.minorRadii[0]) + cylinder = CylinderMesh(fieldmodule, coordinates, elements_count[2], base, + cylinderShape=cylinderShape, + cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False, + rangeOfRequiredElementsAlong=[-1, -1]) + + # skip generating common nodes with the part1. + cylinder.generateNodes(nodes, fieldmodule, coordinates, node_ranges) + + # add the common node parameters. + cylinder_shield = cylinder.getShield() + for n2 in range(elements_count[1] + 1): + for n1 in range(elements_count[0] + 1): + cylinder_shield.nodeId[n3][n2][n1] = part1.nodeId[n3p][n2][n1] + cylinder_shield.px[n3][n2][n1] = part1.px[n3p][n2][n1] + cylinder_shield.pd1[n3][n2][n1] = part1.pd1[n3p][n2][n1] + cylinder_shield.pd2[n3][n2][n1] = part1.pd2[n3p][n2][n1] + cylinder_shield.pd3[n3][n2][n1] = part1.pd3[n3p][n2][n1] + + cylinder.generateElements(mesh, fieldmodule, coordinates) + self.cylinder = cylinder + + def get_cylinder(self): + return self.cylinder + + +class BranchCap: + """ + Create a cap to attach to the given scaffold. + """ + def __init__(self, fieldmodule, coordinates, mesh, nodes, part1, radius): + """ + A hemisphere scaffold to attach to the part1 scaffold. + :param part1: Scaffold with shield structure at its end. + """ + sphere_shape = SphereShape.SPHERE_SHAPE_FULL + sphere_base = part1._ellipses[-1] + sphere_centre = sphere_base.centre + sphere_radius_3 = radius + axes = [sphere_base.majorAxis, sphere_base.minorAxis, + vector.setMagnitude(vector.crossproduct3(sphere_base.majorAxis, sphere_base.minorAxis), + sphere_radius_3)] + elementsCountAcross = [part1._elementsCountAcrossMajor, part1._elementsCountAcrossMinor, 4] + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [0, -1]] + sphereBoxDerivatives = [1, 3, 2] + + sphere1 = SphereMesh(fieldmodule, coordinates, sphere_centre, axes, elementsCountAcross, + 0, 1, 1.0, + sphereShape=sphere_shape, rangeOfRequiredElements=rangeOfRequiredElements, + boxDerivatives=sphereBoxDerivatives, useCrossDerivatives=False) + + hemisphere = ShieldMesh3D(elementsCountAcross, 0) + + # get hemisphere nodes from both cylinder end and top of the sphere and mix them + btx = hemisphere.px + btd1 = hemisphere.pd1 + btd2 = hemisphere.pd2 + btd3 = hemisphere.pd3 + + hemisphere._boxDerivatives = sphere1._shield3D._boxDerivatives + hemisphere._boxMapping = sphere1._shield3D._boxMapping + hemisphere._box_deriv_mapping = sphere1._shield3D._box_deriv_mapping + hemisphere._element_needs_scale_factor = sphere1._shield3D._element_needs_scale_factor + hemisphere._xi_mapping = sphere1._shield3D._xi_mapping + hemisphere._xi_signs = sphere1._shield3D._xi_signs + + for n3 in range(elementsCountAcross[2] + 1): + for n2 in range(elementsCountAcross[0] + 1): + for n1 in range(elementsCountAcross[1] + 1): + if n3 > elementsCountAcross[2] // 2: + if sphere1._shield3D.px[n3][n2][n1]: + # hemisphere.nodeId[n3][n2][n1] = sphere1._shield3D.nodeId[n3][n2][n1] + btx[n3][n2][n1] = sphere1._shield3D.px[n3][n2][n1] + btd1[n3][n2][n1] = sphere1._shield3D.pd1[n3][n2][n1] + btd2[n3][n2][n1] = sphere1._shield3D.pd2[n3][n2][n1] + btd3[n3][n2][n1] = sphere1._shield3D.pd3[n3][n2][n1] + + # cylinder end + elif n3 == elementsCountAcross[2] // 2: + # find nodes on the triple line. Note that cylinder and sphere have a little bit different + # numbering for nodes on the triple line + n2c, n1c = n2, n1 + if n2 < 1 and n1 == n2: + n1c = 1 + elif n2 < 1 and n1 == elementsCountAcross[1] - n2: + n1c = elementsCountAcross[1] - 1 + elif n2 > elementsCountAcross[1] - 1: + if n1 == elementsCountAcross[1] - n2: + n1c = 1 + elif n1 == n2: + n1c = elementsCountAcross[1] - 1 + hemisphere.nodeId[n3][n2][n1] = part1._shield.nodeId[-1][n2c][n1c] + + # generate hemisphere extra nodes. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [3, 4]] + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + nodeIdentifier = hemisphere.generateNodes(fieldmodule, coordinates, nodeIdentifier, + rangeOfRequiredElements) + + # generate hemisphere elements. + rangeOfRequiredElements = [[0, elementsCountAcross[0]], [0, elementsCountAcross[1]], [2, 4]] + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + elementIdentifier = hemisphere.generateElements(fieldmodule, coordinates, elementIdentifier, + rangeOfRequiredElements) + + self.sphere = hemisphere + + def get_sphere(self): + return self.sphere - def __init__(self, fieldModule, coordinates, region): + +class BranchType(Enum): + RIGHT_ARM = 1 + NECK = 2 + LEFT_ARM = 3 + + +class TrifurcationMesh: + """ + Trifurcation mesh generator. + """ + def __init__(self, fieldmodule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, + shoulder_height, neck_height, right_arm_angle, left_arm_angle, right_shoulder_length, armpit, + elements_count): """ - :param fieldModule: Zinc fieldModule to create elements in. + :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. + :param region: Zinc region + :param torso_radius: upper torso radius + :param left_arm_radius: + :param right_arm_radius: + :param neck_radius: + :param shoulder_height: + :param neck_height: + :param right_arm_angle: + :param left_arm_angle: + :param right_shoulder_length: + :param armpit: + :param elements_count: """ + # generate the mesh elementsCount = [2, 2, 5] self._elementsCount = elementsCount + self._elements_count = elements_count self._region = region - self.createBifurcationMesh3d(fieldModule, coordinates) - - def createBifurcationMesh3d(self, fieldmodule, coordinates): + self.torso_radius = torso_radius + self.left_arm_radius = left_arm_radius + self.right_arm_radius = right_arm_radius + self.neck_radius = neck_radius + self.shoulder_height = shoulder_height + self.neck_height = neck_height + self.right_arm_angle = right_arm_angle + self.left_arm_angle = left_arm_angle + self.right_shoulder_length = right_shoulder_length + self.armpit = armpit + + self._coordinates = coordinates + self._fieldmodule = fieldmodule + self._nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + self._mesh = fieldmodule.findMeshByDimension(3) + + self._torso_upper_part = None + self._shoulder_part = None + self._shoulder_part_left = None + self._neck_part = None + + self.createTrifurcationMesh3d(fieldmodule, coordinates) + + def createTrifurcationMesh3d(self, fieldmodule, coordinates): """ - Create a bifurcation. - :param fieldModule: Zinc fieldModule to create elements in. + Create a trifurcation. + :param fieldmodule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. :return: Final values of nextNodeIdentifier, nextElementIdentifier. """ - # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' - # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' - # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ - # ' is not an even number' - # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' - # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, - # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ - # 'createCylinderMesh3d: Invalid cylinder mode.' - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - mesh = fieldmodule.findMeshByDimension(3) - - nodeparams1, nodeparams2 = self._get_node_params() - - bottom_part = BaseLeg(self._elementsCount, nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - - shoulder_part = BaseLeg(self._elementsCount, nodeparams2) + nodes = self._nodes + mesh = self._mesh + base_c, shoulder_lc, shoulder_rc, neck_c = self._get_node_params() + + elementsCount = self._elements_count + # elementsCount = [6,6,2] + torso_upper_part = BaseLeg(elementsCount, base_c) + self.generateNodes(nodes, fieldmodule, coordinates, torso_upper_part) + self.generateElements(mesh, fieldmodule, coordinates, torso_upper_part) + self._torso_upper_part = torso_upper_part + + shoulder_part = BaseLeg(elementsCount, shoulder_lc, shoulder_right=True) shoulder_part._shoulder = True - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) - self.generateElements(mesh, fieldmodule, coordinates, bottom_part) - self.remove_duplicate_nodes_from_shoulder(shoulder_part) self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) - self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) - - joining_box = JoiningBox([1, 4, 1]) - self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) - self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - x_shoulder_base_centre = [-0.5, 0.0, 2.2] - x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] - x_shoulder_base_curve1 = [-0.5, 1.0, 2.2] - d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] - x_shoulder_end_centre = [-1.7, 0.0, 2.2] - x_shoulder_end_curve2 = [-1.7, 0.0, 1.2] - x_shoulder_end_curve1 = [-1.7, 1.0, 2.2] - d1_shoulder_end_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]] - d1_shoulder_end_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - - nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, - d1_shoulder_base_curve2], - [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, - d1_shoulder_end_curve2]] - - shoulder_part = BaseLeg(self._elementsCount, nodeparams3) - shoulder_part._shoulder = True - - self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) - self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) + self.join_shoulder_to_bottom_part(shoulder_part, torso_upper_part) self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) - - - - x_neck_base_centre = [0.0, 0.0, 2.62] - x_neck_base_curve2 = [0.0, 1.0, 2.62] - x_neck_base_curve1 = [1.2, 0.0, 3.4] - d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] - x_neck_end_centre = [0.0, 0.0, 3.6] - x_neck_end_curve2 = [0.0, 0.8, 3.6] - x_neck_end_curve1 = [0.8, 0.0, 3.6] - d1_neck_end_curve2 = [[0.0, 0.8 / self._elementsCount[1], 0.0], [0.0, 0.8 / self._elementsCount[1], 0.0]] - d1_neck_end_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [1 / self._elementsCount[0], 0.0, 0.0]] - - nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, - d1_neck_base_curve2], - [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, - d1_neck_end_curve2]] - - neck_part = BaseLeg(self._elementsCount, nodeparams3) - neck_part._shoulder = True - - # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) + self._shoulder_part = shoulder_part + + shoulder_part_left = BaseLeg(elementsCount, shoulder_rc, shoulder_left=True) + shoulder_part_left._shoulder_left = True + self.remove_duplicate_nodes_from_shoulder(shoulder_part_left, 1) + self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part_left) + self.join_shoulder_to_bottom_part(shoulder_part_left, torso_upper_part, 1) + self.generateElements(mesh, fieldmodule, coordinates, shoulder_part_left) + self._shoulder_part_left = shoulder_part_left + + neck_part = BaseLeg(elementsCount, neck_c) + neck_part._neck = True + self.remove_duplicate_nodes_from_neck(neck_part) self.generateNodes(nodes, fieldmodule, coordinates, neck_part) - # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) + self.join_neck_to_torso(neck_part, shoulder_part, shoulder_part_left) self.generateElements(mesh, fieldmodule, coordinates, neck_part) + self._neck_part = neck_part + + box_part = BoxPart([elementsCount[0] - 2, elementsCount[1], elementsCount[0] - 2], torso_upper_part, + shoulder_part, shoulder_part_left, neck_part) + self.generateNodes(nodes, fieldmodule, coordinates, box_part) + self.generateElements(mesh, fieldmodule, coordinates, box_part) + + def create_branch_cylinder(self, radius, length, number_of_elements, path_list=None, + part1=None, attach_bottom=True, branch_type=BranchType.LEFT_ARM): + """ + Creates a cylinder attached to the part1 + :param radius: + :param length: + :param number_of_elements: + :param path_list: + :param part1: + :param attach_bottom: + :param branch_type: + :return: + """ + if branch_type == BranchType.LEFT_ARM: + part1 = self._shoulder_part + elif branch_type == BranchType.RIGHT_ARM: + part1 = self._shoulder_part_left + elif branch_type == BranchType.NECK: + part1 = self._neck_part + + if not path_list: + pn = PathNodes(part1, radius, length, number_of_elements, attach_bottom=attach_bottom) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, number_of_elements, part1, attach_bottom=attach_bottom) + cylinder = bc.get_cylinder() + + return cylinder + + def create_branch_cap(self, part1, radius): + """ + Creates a cap attached to the part1 + :param part1: + :param radius: + :return: + """ + cap = BranchCap(self._fieldmodule, self._coordinates, self._mesh, self._nodes, part1, radius) - # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) - # - # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) - # - # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] - # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] - # - # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] - # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] - # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] - # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] - # d11 = vector.addVectors([p1, centre], [1, -1]) - # d21 = vector.addVectors([outer_point, centre], [1, -1]) - # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) - - - # centralPath = ScaffoldPackage(MeshType_1d_path1, { - # 'scaffoldSettings': { - # 'Coordinate dimensions': 3, - # 'D2 derivatives': True, - # 'D3 derivatives': True, - # 'Length': 3.0, - # 'Number of elements': 4 - # }, - # 'meshEdits': exnodeStringFromNodeValues( - # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] - # ]) - # }) - # - # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) - # - # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - # - # base = CylinderEnds(4, 4, 0, 1, 1.0, - # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - # cylinderCentralPath.minorRadii[0]) - # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, - # cylinderShape=cylinderShape, - # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - - # joining_torso = JoiningTorso([4, 4, 1]) - # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) - # print(joining_torso.nodeId) - # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) - # - # - # torso_part = torso_cylinder._shield - - -# -4.990e+00, -7.830e-01, 5.4884e+00 -# -# -# -# -6.480e+00, 1.118e-01, 3.8448e+00 -# -# -4.947e+00, 1.216e-01, 5.4829e+00 -# -# -6.004e+00, -6.005e-01, 3.3709e+00 -#-6.031e+00, 9.325e-02, 3.393e+00 - -# -6.496e+00, -5.925e-01, 3.8599e+00 - - # -6.031e+00, 9.325e-02, 3.393e+00 - - # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], - # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], - # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], - # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] - - # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) - # - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) - # - # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], - # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], - # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], - # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] - # - # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], - # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], - # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], - # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] - # - # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) - # shoulder_part2._shoulder = True - # - # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) - # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) - # - # joining_box = JoiningBox([1, 4, 1]) - # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - - - - # elementsCount = [2, 2, 5] - # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] - # - # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], - # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] - # - # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], - # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] - # - # - # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - # - # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] - # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] - # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] - # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # - # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) + return cap + def smooth_all_derivatives(self): + smoothing = DerivativeSmoothing(self._region, self._coordinates) + smoothing.smooth(True) + del smoothing def _get_node_params(self): """ - + Get node parameter for the landmarks :return: """ - x_bottom_base_centre = [0.0, 0.0, 0.0] - x_bottom_base_curve1 = [1.0, 0.0, 0.0] - x_bottom_base_curve2 = [0.0, 1.0, 0.0] - d1_bottom_base_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], - [1/self._elementsCount[0], 0.0, 0.0]] - d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - x_bottom_end_centre = [0.0, 0.0, 1.4] - x_bottom_end_curve1 = [1.2, 0.0, 1.0] - x_bottom_end_curve2 = [0.0, 1.0, 1.4] - d1_bottom_end_curve1 = [[1/self._elementsCount[0], 0.0, 0.0], - [0.5*0.7071, 0.0, -0.5*0.7071]] - d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - - nodeparams1 = [[x_bottom_base_centre, x_bottom_base_curve1, x_bottom_base_curve2, d1_bottom_base_curve1, - d1_bottom_base_curve2], - [x_bottom_end_centre, x_bottom_end_curve1, x_bottom_end_curve2, d1_bottom_end_curve1, - d1_bottom_end_curve2]] - - x_shoulder_base_centre = [0.5, 0.0, 2.2] - x_shoulder_base_curve1 = [1.2, 0.0, 1.0] - x_shoulder_base_curve2 = [0.5, 1.0, 2.2] - d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - x_shoulder_end_centre = [1.7, 0.0, 2.2] - x_shoulder_end_curve1 = [1.7, 0.0, 1.2] - x_shoulder_end_curve2 = [1.7, 1.0, 2.2] - d1_shoulder_end_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]] - d1_shoulder_end_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - - nodeparams2 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, - d1_shoulder_base_curve2], - [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, - d1_shoulder_end_curve2]] - - return nodeparams1, nodeparams2 + class CylinderCurves: + def __init__(self, bottom_curves, top_curves): + self.curves = [bottom_curves, top_curves] + + class EllipseCurves: + def __init__(self, x_curve1, d1_curve1, x_curve2, d1_curve2): + x_curve2[0] = [c for c in x_curve1[0]] + self.xc1 = x_curve1 + self.d1c1 = d1_curve1 + self.xc2 = x_curve2 + self.d1c2 = d1_curve2 + + armpit = self.armpit + + elementsCountQuarter = [3,3,2] + bc = EllipseCurves([[0.0, 0.0, 0.0], [self.torso_radius, 0.0, 0.0]], + [[self.torso_radius / elementsCountQuarter[0], 0.0, 0.0]]*2, + [[0.0, 0.0, 0.0], [0.0, self.torso_radius, 0.0]], + [[0.0, 1/elementsCountQuarter[1], 0.0]]*2) + + tc = EllipseCurves([[0.0, 0.0, 1.4], armpit], + [[1 / elementsCountQuarter[0], 0.0, 0.0], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[0.0, 0.0, 1.4], [0.0, 1.0, 1.4]], + [[0.0, 1 / elementsCountQuarter[1], 0.0]]*2) + + base_c = CylinderCurves(bc, tc) + + x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] + kv = [0.0, 1.0, 0.0] + cv = [self.right_shoulder_length, 0.0, 0.0] + cev = vector.rotateVectorAroundVector(cv, kv, self.left_arm_angle) + cevunit = vector.normalise(cev) + ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) + x_shoulder_end_curve1 = vector.addVectors( + [ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.left_arm_radius)], [1, 1]) + x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.left_arm_radius)], [1, 1]) + d1_shoulder_end_curve1 = [vector.setMagnitude(vector.crossproduct3(kv, cev), + self.left_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0]]*2 + + bc = EllipseCurves([[0.75, 0.0, self.shoulder_height], armpit], + [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], + [[0.75, 0.0, self.shoulder_height], [0.75, 1.0, self.shoulder_height]], + [[0.0, 1 / self._elementsCount[0], 0.0]]*2) + tc = EllipseCurves([ce, x_shoulder_end_curve1], d1_shoulder_end_curve1, + [ce, x_shoulder_end_curve2], d1_shoulder_end_curve2) + shoulder_lc = CylinderCurves(bc, tc) + + x_shoulder_base_centre = [-0.75, 0.0, self.shoulder_height] + kv = [0.0, 1.0, 0.0] + cv = [-self.right_shoulder_length, 0.0, 0.0] + cev = vector.rotateVectorAroundVector(cv, kv, -self.right_arm_angle) + ce = vector.addVectors([cev, x_shoulder_base_centre], [1, 1]) + x_shoulder_end_curve2 = vector.addVectors( + [ce, vector.setMagnitude(vector.crossproduct3(cev, kv), self.right_arm_radius)], [1, 1]) + x_shoulder_end_curve1 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) + d1_shoulder_end_curve2 = [vector.setMagnitude(vector.crossproduct3(cev, kv), + self.right_arm_radius/self._elementsCount[1])]*2 + d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0]]*2 + + bc = EllipseCurves([[-0.75, 0.0, self.shoulder_height], [-0.75, 1.0, self.shoulder_height]], + [[-0.0, 1 / self._elementsCount[0], 0.0]]*2, + [[-0.75, 0.0, self.shoulder_height], [-armpit[0], armpit[1], armpit[2]]], + [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]]) + tc = EllipseCurves([ce, x_shoulder_end_curve1], d1_shoulder_end_curve1, + [ce, x_shoulder_end_curve2], d1_shoulder_end_curve2) + shoulder_rc = CylinderCurves(bc, tc) + + x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] + x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] + d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0]]*2 + d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] + x_neck_end_centre = [0.0, 0.0, self.neck_height] + x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] + x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] + d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0]]*2 + d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0]]*2 + + bc = EllipseCurves([x_neck_base_centre, x_neck_base_curve1], d1_neck_base_curve1, + [x_neck_base_centre, x_neck_base_curve2], d1_neck_base_curve2) + tc = EllipseCurves([x_neck_end_centre, x_neck_end_curve1], d1_neck_end_curve1, + [x_neck_end_centre, x_neck_end_curve2], d1_neck_end_curve2) + neck_c = CylinderCurves(bc, tc) + + return base_c, shoulder_lc, shoulder_rc, neck_c def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): """ - + Attach torso to shoulder :param joining_torso: - :param shoulder_part: - :param bottom_part: + :param shoulder_joint: + :param bottom_joint: :return: """ for n2 in range(joining_torso._elementsCount[1] + 1): @@ -357,20 +494,20 @@ def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] - - - - - def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): + def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, + cidxs, bidx): """ :param shoulder_connecting_to_box: :param joining_box: - :param shoulder_part: + :param cylinder_part: + :param cidxs: + :param bidx: :return: """ for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): - for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): + for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, + shoulder_connecting_to_box._elementsCount[0] + 1): shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] @@ -408,7 +545,7 @@ def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): """ :param shoulder_part: - :param bottom_part: + :param c: :return: """ def condition(n2, n1): @@ -426,7 +563,6 @@ def condition(n2, n1): shoulder_part.pd2[n3][n2][n1] = None shoulder_part.pd3[n3][n2][n1] = None - def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): """ @@ -435,10 +571,6 @@ def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): :return: """ def condition(n2, n1): - # if c: - # n2, n1 = n1, n2 - # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ - # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) if c: return n2 == 0 or n2 == 1 else: @@ -447,11 +579,11 @@ def condition(n2, n1): def index(n2, n1): if c: if n2 == 0 and n1 == 1: - return n1 - 1, 4 - n2 - 1 - if n2 == 0 and n1 == 3: - return n1 + 1, 4 - n2 - 1 + return n1 - 1, shoulder_part._elementsCount[0] - n2 - 1 + if n2 == 0 and n1 == shoulder_part._elementsCount[0] - 1: + return n1 + 1, shoulder_part._elementsCount[0] - n2 - 1 else: - return n1, 4 - n2 + return n1, shoulder_part._elementsCount[0] - n2 else: return n2, n1 @@ -467,9 +599,11 @@ def index(n2, n1): shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] - def copyBaseLeg2Bifurcation(self, baseleg, idx): + def copyBaseLeg2Trifurcation(self, baseleg, idx): """ + :param baseleg: + :param idx: :return: """ for n3 in range(self._elementsCount[2]//2 + 1): @@ -484,12 +618,64 @@ def copyBaseLeg2Bifurcation(self, baseleg, idx): self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] if idx == 2 and n3 == 0: - if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): + if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and + n1 == 1): self.px[n3s][n2][n1] = None self.pd1[n3s][n2][n1] = None self.pd2[n3s][n2][n1] = None self.pd3[n3s][n2][n1] = None + def remove_duplicate_nodes_from_neck(self, neck_part): + """ + + :param neck_part: + :return: + """ + for n2 in range(neck_part._elementsCount[1] + 1): + for n1 in range(neck_part._elementsCount[0] + 1): + if n1 <= 1 or n1 >= neck_part._elementsCount[0] - 1: + neck_part.px[0][n2][n1] = None + neck_part.pd1[0][n2][n1] = None + neck_part.pd2[0][n2][n1] = None + neck_part.pd3[0][n2][n1] = None + + def join_neck_to_torso(self, neck_part, shoulder_part, shoulder_part_left): + """ + + :param neck_part: + :param shoulder_part: + :param shoulder_part_left: + :return: + """ + for n2 in range(neck_part._elementsCount[1] + 1): + for n1 in range(neck_part._elementsCount[0] + 1): + if n1 < 2: + n1s = neck_part._elementsCount[0] - n1 + neck_part.nodeId[0][n2][n1] = shoulder_part.nodeId[0][n2][n1s] + neck_part.px[0][n2][n1] = shoulder_part.px[0][n2][n1s] + neck_part.pd1[0][n2][n1] = shoulder_part.pd1[0][n2][n1s] + neck_part.pd2[0][n2][n1] = shoulder_part.pd2[0][n2][n1s] + neck_part.pd3[0][n2][n1] = shoulder_part.pd3[0][n2][n1s] + elif n1 >= neck_part._elementsCount[0] - 1: + if n2 == 0 or n2 == neck_part._elementsCount[1]: + if n1 == neck_part._elementsCount[0] - 1: + n2s = n1+1 + if n2 == 0: + n1s = n2 + 1 + if n2 == neck_part._elementsCount[1]: + n1s = n2 - 1 + else: + n2s = n1 + n1s = n2 + if n1 == 4: + if n2 !=2: + continue + neck_part.nodeId[0][n2][n1] = shoulder_part_left.nodeId[0][n2s][n1s] + neck_part.px[0][n2][n1] = shoulder_part_left.px[0][n2s][n1s] + neck_part.pd1[0][n2][n1] = shoulder_part_left.pd1[0][n2s][n1s] + neck_part.pd2[0][n2][n1] = shoulder_part_left.pd2[0][n2s][n1s] + neck_part.pd3[0][n2][n1] = shoulder_part_left.pd3[0][n2s][n1s] + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): """ Create cylinder nodes from coordinates. @@ -511,7 +697,8 @@ def generateElements(self, mesh, fieldModule, coordinates, part_structure): """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier - elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, + []) self._endElementIdentifier = elementIdentifier def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): @@ -536,10 +723,14 @@ def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, p node = nodes.createNode(nodeIdentifier, nodetemplate) part_structure.nodeId[n3][n2][n1] = nodeIdentifier cache.setNode(node) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, + part_structure.px[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, + part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, + part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, + part_structure.pd3[n3][n2][n1]) nodeIdentifier += 1 return nodeIdentifier @@ -582,50 +773,904 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif for e1 in range(part_structure._elementsCount[0]): eft1 = eft scalefactors = None - # if e3 >= 3: - # e3t = e3 + 1 - # else: - # e3t = e3 - # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], - # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], - # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], - # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] - nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], - part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], - part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], - part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] - - if isinstance(part_structure, JoiningBox): - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - if e2 == e2a or e2 == e2z: + nids = [part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1]] + + if isinstance(part_structure, BoxPart): + if e3 == 0: + if e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == 0: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == part_structure._elementsCount[1]: + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + + if e2 == e2a or e2 == e2z: + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + + else: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e3 == part_structure._elementsCount[2] - 1: + if e1 == 0: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [1])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, []), (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e1 == 0: + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1, 2, 3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) + else: + if e2 == e2a: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif e2 == e2z: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + elif part_structure._neck and e3 == 0: + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 == e2a) or (e2 == e2z): + # bottom and top row elements if e2 == e2a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e1 == e1a: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, []), + (Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1]), + (Node.VALUE_LABEL_D_DS1, [])]) + + elif e1b < e1 < e1y: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + + [(Node.VALUE_LABEL_D_DS1, [])]) + + else: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [1])]) + # if (e1 == e1b) or (e1 == e1y): + if e1 == e1b: + # map bottom triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2z: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1y: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + elif e1b < e1 < e1y: + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + if e3 == 0: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + if e3 == 0: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.nodeId[e3+1][e2a][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + elif e2 == e2y: + nids[5] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + if e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + if e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + elif e2b < e2 < e2y: + if e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1]), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + elif e1 == e1y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) + if e1 < e1a: + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + 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])]) else: if (e2 < e2b) or (e2 > e2y): @@ -633,89 +1678,179 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif continue # no element due to triple point closure if (e2 < e2a) or (e2 > e2z): if e2 < e2a: - nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], - part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + nids = [part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1]] elif e2 > e2z: - nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], - part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + nids = [part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1]] elif (e2 == e2a) or (e2 == e2z): # bottom and top row elements if e2 == e2a: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] - # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: - # e3r = e3t-1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - - # if e3 == 2: - # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # elif e3 == 3: - # if e1 == e1b: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - if isinstance(part_structure, BaseLeg): - if part_structure._shoulder: - if e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # else: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - - # else: - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) + if not part_structure._shoulder_left: + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder: + if e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if e3 == 0: + if e2 == 0 and (e1 <= e1y-1 and e1 >= e1b+1): + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, [])]) if (e1 == e1b) or (e1 == e1y): # map bottom triple point element if e1 == e1b: # if e3 != 2: - # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + if part_structure._shoulder: + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) else: - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + else: + remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e2 == e2z: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) scalefactors = [-1.0] if isinstance(part_structure, BaseLeg): if part_structure._shoulder and e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) if (e1 == e1b) or (e1 == e1y): # map top triple point element if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + if e3 == 0: + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + if part_structure._shoulder: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) else: - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): if e1 < e1a: e2r = e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], - part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] + nids = [part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3+1][e2c][e1+1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1b]] if e2 == e2y: e2r = 2*part_structure._elementsCount[1] - e1-1 - nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], - part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] + nids = [part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3][e2y][e1+1], + part_structure.nodeId[e3+1][e2r][e1b], + part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3][e2y][e1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3+1][e2y][e1]] elif e1 == e1a: eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) @@ -731,34 +1866,90 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif else: nids[0] = part_structure.nodeId[e3][e2a][e1b] nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - tripleN = [5, 7] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + tripleN = [5, 7] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif e2 == e2y: nids[1] = part_structure.nodeId[e3][e2z+1][e1b] nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] tripleN = [6, 8] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - 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] ) ]) + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + 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])]) + if e3 == 0: + if part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) elif e1 == e1z: eft1 = tricubichermite.createEftNoCrossDerivatives() if e2 == e2b: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] nids[4] = part_structure.nodeId[e3][e2a][e1z] nids[6] = part_structure.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, [] ) ]) + scalefactors = [-1.0] + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + 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] = part_structure.nodeId[e3][e2z+1][e1z] nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) elif e1 > e1z: e2r = part_structure._elementsCount[0] - e1 if e2 == e2b: - nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], - part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] + nids = [part_structure.nodeId[e3][e2r][e1z], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1z], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], + part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3+1][e2r-1][e1z], + part_structure.nodeId[e3+1][e2c][e1+1]] elif e2 == e2y: e2r = e2z+e1-e1z nids[1] = part_structure.nodeId[e3][e2r][e1z] @@ -768,67 +1959,92 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif elif e1 == e1b: if e2 == e2b: eft1 = tricubichermite.createEftNoCrossDerivatives() - # if e3 == part_structure._elementsCount[2] // 2 + 1: - # e3r = e3 - 1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # if e3 == 2: - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - - - - + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if part_structure._shoulder: + if e3 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + + if e2 == e2y: + if part_structure._shoulder: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + + elif e1 == e1y: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._shoulder_left: + if e3 == 0: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + + else: + if part_structure._shoulder_left: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and e2 <= e2b: + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) else: if e1 < e1a: - nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] elif e1 == e1a: # map left column elements eft1 = tricubichermite.createEftNoCrossDerivatives() setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) - - # if e3 == 2: - # if e1 == e1b: - # # joining elements - # if e2 == 0: - # nids = [15, 17, 22, 24, 16, 18, 23, 25] - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - - - - - # elif e2 == 1: - # nids = [17, 20, 24, 26, 18, 21, 25, 27] + scalefactors = [-1.0] + 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])]) + if e3 == 0 and part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and part_structure._shoulder: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) if not all(nids): continue @@ -843,7 +2059,6 @@ def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentif result3 = element.setScaleFactors(eft1, scalefactors) else: result3 = 7 - #print('create element shield', elementIdentifier, result2, result3, nids) part_structure.elementId[e3][e2][e1] = elementIdentifier elementIdentifier += 1 @@ -857,32 +2072,46 @@ class BaseLeg: """ Base case for creating a child """ - def __init__(self, elementsCount, nodeparams): + def __init__(self, elementsCount, cyl_curves, shoulder_right=False, shoulder_left=False): """ - :param fieldmodule: - :param coordinates: - :param mesh: - :param nodes: + :param elementsCount: + :param cyl_curves: + :param shoulder_right: + :param shoulder_left: """ - elementsCount = [4, 4, 2] self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] - self.nodeparams = nodeparams self._shoulder = False - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - self.generateBaseLeg(nodeparams) - - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) + self._shoulder_left = False + self._neck = False + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] + self.generateBaseLeg(cyl_curves.curves) + + bc = cyl_curves.curves[0] + tc = cyl_curves.curves[1] + n, d = geometry.get_plane_normal_vector_and_distance(bc.xc1[0], bc.xc1[1], tc.xc1[0]) plane = [n[0], n[1], n[2], d] - mirror = Mirror(plane) + mirrore = Mirror(plane) + if shoulder_left: + mirror0 = Mirror([0.0, 0.0, 1.0, bc.xc1[0][2]]) for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): for n3 in range(elementsCount[2]+1): + if shoulder_left and n3 == 0: + mirror = mirror0 + else: + mirror = mirrore for n1 in range(elementsCount[0]//2+1): n3q = n3 n2q = elementsCount[1] - n2 @@ -893,11 +2122,17 @@ def __init__(self, elementsCount, nodeparams): self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) + n, d = geometry.get_plane_normal_vector_and_distance(bc.xc1[0], bc.xc2[1], tc.xc1[0]) plane = [n[0], n[1], n[2], d] - mirror = Mirror(plane) + mirrore = Mirror(plane) + if shoulder_right: + mirror0 = Mirror([0.0, 0.0, 1.0, bc.xc1[0][2]]) for n2 in range(elementsCount[1]+1): for n3 in range(elementsCount[2]+1): + if shoulder_right and n3 == 0: + mirror = mirror0 + else: + mirror = mirrore for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): n3q = n3 n2q = n2 @@ -911,56 +2146,58 @@ def __init__(self, elementsCount, nodeparams): self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) + + # sample in between ellipses + btx = self.px + btd1 = self.pd1 + btd2 = self.pd2 + btd3 = self.pd3 + elementsCountOut = 2 + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + if btx[0][n2][n1]: + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves( + [btx[0][n2][n1], btx[self._elementsCount[2]][n2][n1]], + [btd2[0][n2][n1], btd2[self._elementsCount[2]][n2][n1]], + elementsCountOut) + td1 = interpolateSampleCubicHermite( + [btd1[0][n2][n1], btd1[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [btd3[0][n2][n1], btd3[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + + for n3 in range(1, self._elementsCount[2]): + n3i = n3 + self.px[n3][n2][n1] = tx[n3i] + self.pd1[n3][n2][n1] = td1[n3i] + self.pd2[n3][n2][n1] = td2[n3i] + self.pd3[n3][n2][n1] = td3[n3i] + self._elementsCount = elementsCount - def generateBaseLeg(self, nodeparams): + def generateBaseLeg(self, surface_curves): """ Generate base leg that is a cylinder generated from cylinder ends. :return: """ - bottomnodeparams = nodeparams[0] - topnodeparams = nodeparams[1] - self.genetateBottomSurface(bottomnodeparams) - self.generateTopSurface(topnodeparams) + bottom_curves = surface_curves[0] + top_curves = surface_curves[1] + self.generate_surface(bottom_curves, 0) + self.generate_surface(top_curves, self._elementsCount[2]) self.generateMiddleLevels() self.smoothd2() - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateMiddleLevels() - # self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - def genetateBottomSurface(self, bottomnodeparams): - """ - Use major and minor curves to generate the ellipse - :return: - """ - centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, 0) - - def generateTopSurface(self, topnodeparams): + def generate_surface(self, curves, n3): """ :return: """ - centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) + centre = curves.xc1[0] + txc1, td1c1 = self.generate1DPath(curves.xc1, curves.d1c1, self._elementsCount[0]) + txc2, td1c2 = self.generate1DPath(curves.xc2, curves.d1c2, self._elementsCount[1]) ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) + self.copyEllipseNodesToTrifurcation(ellipse, n3) def generateMiddleLevels(self): """ @@ -971,39 +2208,31 @@ def generateMiddleLevels(self): btd1 = self.pd1 btd2 = self.pd2 btd3 = self.pd3 + # generate the armpit curves. elementsCountOut = 2 - txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], - btx[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [btd2[0][self._elementsCount[1]][self._elementsCount[0]], - btd2[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - elementsCountOut) - txec1, td1ec1, pec1, pxic1, psfc1 = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][0], btx[self._elementsCount[2]][self._elementsCount[1]][0]], - [btd2[0][self._elementsCount[1]][0], btd2[self._elementsCount[2]][self._elementsCount[1]][0]], - elementsCountOut) - txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]], btx[self._elementsCount[2]][0][self._elementsCount[0]]], - [btd2[0][0][self._elementsCount[0]], btd2[self._elementsCount[2]][0][self._elementsCount[0]]], - elementsCountOut) - - tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][self._elementsCount[0]], - btd3[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]][self._elementsCount[0]], - btd1[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlec1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][0], - btd3[self._elementsCount[2]][self._elementsCount[1]][0]], - [[0.0, 0.0, 0.0]] * 2, pec1, pxic1, psfc1)[0] - tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]], - btd3[self._elementsCount[2]][0][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] - - for n3 in range(1, self._elementsCount[2]): - centre = txcc1[n3] - txc1, td1c1 = self.generate1DPath([centre, txec1[n3]], [[-c for c in tdlcc1[n3]], tdlec1[n3]], self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, n3) + + # sample in between ellipses + for n2 in range(self._elementsCount[1] + 1): + for n1 in range(self._elementsCount[0] + 1): + if btx[0][n2][n1]: + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves( + [btx[0][n2][n1], btx[self._elementsCount[2]][n2][n1]], + [btd2[0][n2][n1], btd2[self._elementsCount[2]][n2][n1]], + elementsCountOut) + td1 = interpolateSampleCubicHermite( + [btd1[0][n2][n1], btd1[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [btd3[0][n2][n1], btd3[self._elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + + for n3 in range(1, self._elementsCount[2]): + n3i = n3 + self.px[n3][n2][n1] = tx[n3i] + self.pd1[n3][n2][n1] = td1[n3i] + self.pd2[n3][n2][n1] = td2[n3i] + self.pd3[n3][n2][n1] = td3[n3i] def smoothd2(self): """ @@ -1024,7 +2253,9 @@ def smoothd2(self): nx.append(btx[n3][n2][n1]) nd1.append(btd2[n3][n2][n1]) td2 = smoothCubicHermiteDerivativesLine(nx, nd1) - for n3 in range(self._elementsCount[2] + 1): + # if we modify d2 here then it would not be exactly orthogonal to d1 and d3. This makes d2 not + # be normal to plane + for n3 in range(self._elementsCount[2]+1): btd2[n3][n2][n1] = td2[n3] def generate1DPath(self, nx, nd1, elementsCountOut): @@ -1049,8 +2280,11 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] - majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] - minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] + centre_d1c1 = [c for c in td1c1[0]] + centre_d1c2 = [c for c in td1c2[0]] + majorAxis = [c*self._elementsCount[0] for c in centre_d1c2] + minorAxis = [-c*self._elementsCount[1] for c in centre_d1c1] + elementsCountAcrossShell = 0 elementsCountAcrossTransition = 1 shellProportion = 1.0 @@ -1059,16 +2293,20 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) + shellProportion, coreMajorRadius, coreMinorRadius, + ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) shield = ellipse.getShield() ellipse.generateBase1DMesh(0) + # Modify x and d1 for nodes on the end of curve 1 and 2. ellipse.px[self._elementsCount[1]][0] = txc1[-1] ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] ellipse.px[0][self._elementsCount[0]] = txc2[-1] ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] + # Bend the surface according to its new curves + # Modify x and d1 for the surface perimeter nx = [] nd1 = [] for n in range(elementsCountAround + 1): @@ -1078,14 +2316,15 @@ def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): # ellipse.px[0][self._elementsCount[0]][2] x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) - delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] + delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] + for c in range(3)] normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) delta_p_normalmag = vector.dotproduct(delta_p, normal) delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) delnormag = vector.dotproduct(delta, normal) delnor = vector.scaleVector(normal, delnormag) - if 0 elementsCount[0]//2: + if i!= 1: + pl[i][n3][n2][n1] = p1v2[i][n2][n1] + else: + if i != 1: + n2r, n1r = n2, elementsCount[0] - n1 + pl[i][n3][n2][n1] = pr[i][n3][n2r][n1r] + + self.generateNodes(nodes, fieldmodule, coordinates, hip_right) + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if n3 == elementsCount[2]: + if n1 > elementsCount[0]//2: + pl[i][n3][n2][n1] = p1v2[i][n2][n1] + self.generateElements(mesh, fieldmodule, coordinates, hip_right) + + pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, [4, 4, 7], hip_left, attach_bottom=False) + cylinder = bc.get_cylinder() + + pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) + path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, + path_list, [4, 4, 7], hip_right, attach_bottom=False) + cylinder = bc.get_cylinder() + + def generateNodes(self, nodes, fieldModule, coordinates, part_structure): + """ + Create cylinder nodes from coordinates. + :param nodes: nodes from coordinates. + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. + """ + nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) + self._startNodeIdentifier = nodeIdentifier + nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) + self._endNodeIdentifier = nodeIdentifier + + def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): + """ + Create shield nodes from coordinates. + """ + nodeIdentifier = startNodeIdentifier + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + nodetemplate = nodes.createNodetemplate() + nodetemplate.defineField(coordinates) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) + nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) + cache = fieldmodule.createFieldcache() + + for n3 in range(1 + 1): # TODO should change to number of elements along, major, minor. + for n2 in range(4 + 1): + for n1 in range(4 + 1): + if part_structure.px[n3][n2][n1]: + node = nodes.createNode(nodeIdentifier, nodetemplate) + part_structure.nodeId[n3][n2][n1] = nodeIdentifier + cache.setNode(node) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, + part_structure.px[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, + part_structure.pd1[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, + part_structure.pd2[n3][n2][n1]) + coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, + part_structure.pd3[n3][n2][n1]) + nodeIdentifier += 1 + + return nodeIdentifier -class CrotchEllipses: - def __init__(self): + def generateElements(self, mesh, fieldModule, coordinates, part_structure): + """ + Create cylinder elements from nodes. + :param mesh: + :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. + :param coordinates: Coordinate field to define. """ + elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) + self._startElementIdentifier = elementIdentifier + elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, + []) + self._endElementIdentifier = elementIdentifier + def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, 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 meshGroups: Zinc mesh groups to add elements to. + :return: next elementIdentifier. + """ + elementIdentifier = startElementIdentifier + useCrossDerivatives = False + mesh = fieldmodule.findMeshByDimension(3) + + tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) + eft = tricubichermite.createEftNoCrossDerivatives() + elementtemplate = mesh.createElementtemplate() + elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) + elementtemplate.defineField(coordinates, -1, eft) + + elementtemplate1 = mesh.createElementtemplate() + elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) + + # isEven = (self.elementsCountAcross % 2) == 0 + e1a = 0 + e1b = e1a + 1 + e1z = part_structure._elementsCount[0] - 1 + e1y = e1z - 1 + e2a = 0 + e2b = e2a + 1 + e2c = e2a + 2 + e2z = part_structure._elementsCount[1]-1 + e2y = e2z - 1 + # e2x = e2z - 2 + for e3 in range(part_structure._elementsCount[2]): + for e2 in range(part_structure._elementsCount[1]): + for e1 in range(part_structure._elementsCount[0]): + eft1 = eft + scalefactors = None + nids = [part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1]] + + if (e2 < e2b) or (e2 > e2y): + if (e1 < e1b) or (e1 > e1y): + continue # no element due to triple point closure + if (e2 < e2a) or (e2 > e2z): + if e2 < e2a: + nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], + part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], + part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], + part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] + elif e2 > e2z: + nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], + part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], + part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] + elif (e2 == e2a) or (e2 == e2z): + # bottom and top row elements + if e2 == e2a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if part_structure._side == 'left': + # if e3,e2,e1 = 0, 0, 2 + if e1 == e1y: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + + if part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + if e1 == e1y: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + else: + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + elif part_structure._side == 'right': + if e1 == e1b: + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [])]) + + if (e1 == e1b) or (e1 == e1y): + # map bottom triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + else: + + remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if isinstance(part_structure, BaseLeg): + if part_structure._shoulder and e3 == 0 and e1 == e1b: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS2, [])]) + else: + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + # TODO if e3 == -1 + remapEftNodeValueLabel(eft1, [2, 6], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + if part_structure._side == 'left': + if e1 == e1y: + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + else: + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + elif part_structure._side == 'right': + if e1 == e1b: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D2_DS1DS2, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D2_DS1DS2, + [(Node.VALUE_LABEL_D_DS1, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1])]) + remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [2, 6, 8], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS3, [])]) + + if (e1 == e1b) or (e1 == e1y): + # map top triple point element + if e1 == e1b: + remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + else: + remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [])]) + + elif (e2 == e2b) or (e2 == e2y): + if (e1 <= e1a) or (e1 >= e1z): + if e1 < e1a: + e2r = e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3+1][e2c][e1+1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1b]] + if e2 == e2y: + e2r = 2*part_structure._elementsCount[1] - e1-1 + nids = [part_structure.nodeId[e3][e2r][e1b], + part_structure.nodeId[e3][e2y][e1+1], + part_structure.nodeId[e3+1][e2r][e1b], + part_structure.nodeId[e3+1][e2y][e1+1], + part_structure.nodeId[e3][e2r+1][e1b], + part_structure.nodeId[e3][e2y][e1], + part_structure.nodeId[e3+1][e2r+1][e1b], + part_structure.nodeId[e3+1][e2y][e1]] + elif e1 == e1a: + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + if e2 == e2b: + if e3 == part_structure._elementsCount[2] // 2 + 1: + e3r = e3-1 # to join upper leg with the lower leg. + nids[0] = part_structure.nodeId[e3r][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] + nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] + nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] + else: + nids[0] = part_structure.nodeId[e3][e2a][e1b] + nids[2] = part_structure.nodeId[e3+1][e2a][e1b] + tripleN = [5, 7] if part_structure._side == 'left' else [5] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + elif e2 == e2y: + nids[1] = part_structure.nodeId[e3][e2z+1][e1b] + nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] + tripleN = [6, 8] if part_structure._side == 'left' else [6] + remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [])]) + remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS1, + [(Node.VALUE_LABEL_D_DS1, [1])]) + if part_structure._side == 'right': + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + if e2 == e2b: + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), + (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2y: + remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, [1]), + (Node.VALUE_LABEL_D_DS3, [1])]) + elif part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [1, 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 e1 == e1z: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e2 == e2b: + nids[4] = part_structure.nodeId[e3][e2a][e1z] + nids[6] = part_structure.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, [])]) + if part_structure._side == 'left': + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + elif e2 == e2y: + nids[5] = part_structure.nodeId[e3][e2z+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] + remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) + # if e3,e2,e1 = 0 2 3 + if part_structure._side == 'left': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + elif e1 > e1z: + e2r = part_structure._elementsCount[0] - e1 + if e2 == e2b: + nids = [part_structure.nodeId[e3][e2r][e1z], + part_structure.nodeId[e3][e2c][e1], + part_structure.nodeId[e3+1][e2r][e1z], + part_structure.nodeId[e3+1][e2c][e1], + part_structure.nodeId[e3][e2r-1][e1z], + part_structure.nodeId[e3][e2c][e1+1], + part_structure.nodeId[e3+1][e2r-1][e1z], + part_structure.nodeId[e3+1][e2c][e1+1]] + elif e2 == e2y: + e2r = e2z+e1-e1z + nids[1] = part_structure.nodeId[e3][e2r][e1z] + nids[3] = part_structure.nodeId[e3+1][e2r][e1z] + nids[5] = part_structure.nodeId[e3][e2r+1][e1z] + nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] + elif e1 == e1b: + if e2 == e2b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._side == 'right': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + else: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._side == 'right': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS3, [1])]) + + elif e1 == e1y: + if e2 == e2b or e2 == e2y: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if part_structure._side == 'left': + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [1])]) + remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS3, [1])]) + + else: + if e1 < e1a: + nids = [part_structure.nodeId[e3][e2 + 1][e1 + 1], + part_structure.nodeId[e3][e2][e1 + 1], + part_structure.nodeId[e3+1][e2 + 1][e1 + 1], + part_structure.nodeId[e3+1][e2][e1 + 1], + part_structure.nodeId[e3][e2 + 1][e1], + part_structure.nodeId[e3][e2][e1], + part_structure.nodeId[e3+1][e2 + 1][e1], + part_structure.nodeId[e3+1][e2][e1]] + elif e1 == e1a: + # map left column elements + eft1 = tricubichermite.createEftNoCrossDerivatives() + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + 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])]) + if e3 == 0 and part_structure._shoulder: + remapEftNodeValueLabel(eft1, [5, 6], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + + elif e1 == e1b: + eft1 = tricubichermite.createEftNoCrossDerivatives() + if e3 == 0 and part_structure._shoulder: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, + [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [1])]) + remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, + [(Node.VALUE_LABEL_D_DS2, [])]) + + if not all(nids): + continue + + if eft1 is not eft: + elementtemplate1.defineField(coordinates, -1, eft1) + element = mesh.createElement(elementIdentifier, elementtemplate1) + else: + element = mesh.createElement(elementIdentifier, elementtemplate) + result2 = element.setNodesByIdentifier(eft1, nids) + if scalefactors: + result3 = element.setScaleFactors(eft1, scalefactors) + else: + result3 = 7 + part_structure.elementId[e3][e2][e1] = elementIdentifier + elementIdentifier += 1 + + for meshGroup in meshGroups: + meshGroup.addElement(element) + + return elementIdentifier + + +class Hip: + def __init__(self, elementsCount, side): + self._elementsCount = elementsCount + self._side = side + + elementsCount = elementsCount + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] + + +class BoxPart: + def __init__(self, elementsCount, torso, shoulder_left, shoulder_right, neck): + # self._elementsCount = [2, 4, 2] + # self._elementsCount = [4, 6, 4] + self._elementsCount = elementsCount + self._joining_box = True + + # elementsCount = [2, 4, 2] + # elementsCount = [4, 6, 4] + elementsCount = elementsCount + + self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self._px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] + for c in range(elementsCount[2] + 1)] + self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] + for c in range(elementsCount[2])] + + torso_elements_count = [len(torso.px[0][0])-1, len(torso.px[0])-1, len(torso.px)-1] + p = [self.nodeId, self._px, self.pd1, self.pd2, self.pd3] + p1 = [torso.nodeId, torso.px, torso.pd1, torso.pd2, torso.pd3] + p2 = [neck.nodeId, neck.px, neck.pd1, neck.pd2, neck.pd3] + p3 = [shoulder_left.nodeId, shoulder_left.px, shoulder_left.pd1, shoulder_left.pd2, shoulder_left.pd3] + p4 = [shoulder_right.nodeId, shoulder_right.px, shoulder_right.pd1, shoulder_right.pd2, shoulder_right.pd3] + + for n3 in range(elementsCount[2] + 1): + for n2 in range(elementsCount[1] + 1): + for n1 in range(elementsCount[0] + 1): + for i in range(5): + if (n2 == 0 or n2 == elementsCount[1]) and n1 == 0: + n2p, n1p = n2, n1 + 1 + elif (n2 == 0 or n2 == elementsCount[1]) and n1 == torso_elements_count[0] - 2: + n2p, n1p = n2, n1 + 1 + else: + n2p, n1p = n2, n1 + 1 + + if n3 == 0: + p[i][n3][n2][n1] = p1[i][torso_elements_count[2]][n2p][n1p] + elif n3 == elementsCount[2]: + p[i][elementsCount[2]][n2][n1] = p2[i][0][n2p][n1p] + else: + if n1 == 0: + p[i][n3][n2][0] = p3[i][0][n2][n3+1] + elif n1 == elementsCount[0]: + p[i][n3][n2][elementsCount[0]] = p4[i][0][n3+1][n2] + + elementsCountOut = elementsCount[2] + for n2 in range(elementsCount[1] + 1): + for n1 in range(1, elementsCount[0]): + nx = [self._px[0][n2][n1], self._px[elementsCount[2]][n2][n1]] + nd1 = [self.pd2[0][n2][n1], self.pd2[elementsCount[2]][n2][n1]] + tx, td2, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) + td1 = interpolateSampleCubicHermite( + [self.pd1[0][n2][n1], self.pd1[elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + td3 = interpolateSampleCubicHermite( + [self.pd3[0][n2][n1], self.pd3[elementsCount[2]][n2][n1]], + [[0.0, 0.0, 0.0]] * 2, pe, pxi, psf)[0] + for n3 in range(1, elementsCount[2]): + self.px[n3][n2][n1] = tx[n3] + self._px[n3][n2][n1] = tx[n3] + self.pd1[n3][n2][n1] = td1[n3] + self.pd2[n3][n2][n1] = td2[n3] + self.pd3[n3][n2][n1] = td3[n3] diff --git a/src/scaffoldmaker/utils/bifurcation3d3.py b/src/scaffoldmaker/utils/bifurcation3d3.py deleted file mode 100644 index a0a8ad40..00000000 --- a/src/scaffoldmaker/utils/bifurcation3d3.py +++ /dev/null @@ -1,1619 +0,0 @@ -""" -Utility functions for generating a 3-D solid bifurcation. -""" -import copy -from enum import Enum -from scaffoldmaker.utils import vector, geometry -import math -from opencmiss.zinc.field import Field -from opencmiss.utils.zinc.finiteelement import getMaximumNodeIdentifier, getMaximumElementIdentifier -from scaffoldmaker.utils.shieldmesh import ShieldMesh2D, ShieldShape2D, ShieldRimDerivativeMode -from scaffoldmaker.utils.interpolation import sampleCubicHermiteCurves, interpolateSampleCubicHermite, \ - smoothCubicHermiteDerivativesLine, interpolateSampleLinear -from opencmiss.zinc.node import Node -from scaffoldmaker.utils.mirror import Mirror -from scaffoldmaker.meshtypes.meshtype_1d_path1 import extractPathParametersFromRegion -from scaffoldmaker.utils.cylindermesh import Ellipse2D, EllipseShape, CylinderCentralPath, CylinderShape, CylinderEnds, CylinderMesh -from scaffoldmaker.utils.eftfactory_tricubichermite import eftfactory_tricubichermite -from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabel, setEftScaleFactorIds -from opencmiss.zinc.element import Element -from scaffoldmaker.scaffoldpackage import ScaffoldPackage -from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1 -from scaffoldmaker.utils.zinc_utils import exnodeStringFromNodeValues - - -class BifurcationMesh: - """ - Bifurction mesh generator. - """ - - def __init__(self, fieldModule, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, - shoulder_height, neck_height, right_arm_angle, right_arm_length, shoulder_joint, armpit, neck_shoulder, - shoulder_point, shoulder_start): - """ - :param fieldModule: Zinc fieldModule to create elements in. - :param coordinates: Coordinate field to define. - """ - # generate the mesh - elementsCount = [2, 2, 5] - self._elementsCount = elementsCount - self._region = region - - self.torso_radius = torso_radius - self.left_arm_radius = left_arm_radius - self.right_arm_radius = right_arm_radius - self.neck_radius = neck_radius - self.shoulder_height = shoulder_height - self.neck_height = neck_height - self.right_arm_angle = right_arm_angle - self.right_arm_length = right_arm_length - self.shoulder_joint = shoulder_joint - self.armpit = armpit - self.neck_shoulder = neck_shoulder - self.shoulder_point = shoulder_point - self.shoulder_start = shoulder_start - - self.createBifurcationMesh3d(fieldModule, coordinates) - - def createBifurcationMesh3d(self, fieldmodule, coordinates): - """ - Create a bifurcation. - :param fieldModule: Zinc fieldModule to create elements in. - :param coordinates: Coordinate field to define. - :return: Final values of nextNodeIdentifier, nextElementIdentifier. - """ - # assert (self._elementsCountAlong > 0), 'createCylinderMesh3d: Invalid number of along elements' - # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' - # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ - # ' is not an even number' - # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' - # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, - # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ - # 'createCylinderMesh3d: Invalid cylinder mode.' - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - mesh = fieldmodule.findMeshByDimension(3) - - nodeparams1, nodeparams2 = self._get_node_params() - - bottom_part = BaseLeg2([4, 4, 2], nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - - shoulder_part = BaseLeg2([4, 4, 2], nodeparams2) - # shoulder_part._shoulder = True - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - self.generateNodes(nodes, fieldmodule, coordinates, bottom_part) - self.generateElements(mesh, fieldmodule, coordinates, bottom_part) - - # self.remove_duplicate_nodes_from_shoulder(shoulder_part) - self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - # self.join_shoulder_to_bottom_part(shoulder_part, bottom_part) - self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) - # - # joining_box = JoiningBox([1, 4, 1], self.shoulder_height) - # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box) - # - # x_shoulder_base_centre = [-0.5, 0.0, self.shoulder_height] - # x_shoulder_base_curve2 = [-1.2, 0.0, 1.0] - # x_shoulder_base_curve1 = [-0.5, 1.0, self.shoulder_height] - # d1_shoulder_base_curve2 = [[-0.0, 0.0, -1 / self._elementsCount[1]], [-0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - # d1_shoulder_base_curve1 = [[-0.0, 1 / self._elementsCount[0], 0.0], [-0.0, 1 / self._elementsCount[0], 0.0]] - # x_shoulder_end_centre = [-1.7, 0.0, self.shoulder_height] - # x_shoulder_end_curve2 = [-1.7, 0.0, self.shoulder_height - self.right_arm_radius] - # x_shoulder_end_curve1 = [-1.7, self.right_arm_radius, self.shoulder_height] - # d1_shoulder_end_curve2 = [[-0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.right_arm_radius / self._elementsCount[1]]] - # d1_shoulder_end_curve1 = [[-0.0, self.right_arm_radius / self._elementsCount[0], 0.0], [0.0, self.right_arm_radius / self._elementsCount[0], 0.0]] - # - # nodeparams3 = [[x_shoulder_base_centre, x_shoulder_base_curve1, x_shoulder_base_curve2, d1_shoulder_base_curve1, - # d1_shoulder_base_curve2], - # [x_shoulder_end_centre, x_shoulder_end_curve1, x_shoulder_end_curve2, d1_shoulder_end_curve1, - # d1_shoulder_end_curve2]] - # - # shoulder_part = BaseLeg2(self._elementsCount, nodeparams3) - # shoulder_part._shoulder = True - # - # self.remove_duplicate_nodes_from_shoulder(shoulder_part, 1) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part) - # self.join_shoulder_to_bottom_part(shoulder_part, bottom_part, 1) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part) - # - # - # - # x_neck_base_centre = [0.0, 0.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] - # x_neck_base_curve2 = [0.0, 1.0, 2 * self.shoulder_height - 1.0 - self.right_arm_radius/2] - # x_neck_base_curve1 = [1.2, 0.0, 2 * self.shoulder_height - 1.0] - # d1_neck_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - # d1_neck_base_curve1 = [[1 / self._elementsCount[0], 0.0, 0.0], [0.5, 0.0, 0.5]] - # x_neck_end_centre = [0.0, 0.0, self.neck_height] - # x_neck_end_curve2 = [0.0, self.neck_radius, self.neck_height] - # x_neck_end_curve1 = [self.neck_radius, 0.0, self.neck_height] - # d1_neck_end_curve2 = [[0.0, self.neck_radius / self._elementsCount[1], 0.0], [0.0, self.neck_radius / self._elementsCount[1], 0.0]] - # d1_neck_end_curve1 = [[self.neck_radius / self._elementsCount[0], 0.0, 0.0], [self.neck_radius / self._elementsCount[0], 0.0, 0.0]] - # - # nodeparams3 = [[x_neck_base_centre, x_neck_base_curve1, x_neck_base_curve2, d1_neck_base_curve1, - # d1_neck_base_curve2], - # [x_neck_end_centre, x_neck_end_curve1, x_neck_end_curve2, d1_neck_end_curve1, - # d1_neck_end_curve2]] - # - # neck_part = BaseLeg2(self._elementsCount, nodeparams3) - # neck_part._shoulder = True - # - # # self.remove_duplicate_nodes_from_shoulder(neck_part, 1) - # self.generateNodes(nodes, fieldmodule, coordinates, neck_part) - # # self.join_shoulder_to_bottom_part(neck_part, bottom_part, 1) - # self.generateElements(mesh, fieldmodule, coordinates, neck_part) - - # shoulder_connecting_to_box = CylinderConnectingToBox(shoulder_part, [0, 0], -1) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(shoulder_connecting_to_box, joining_box, shoulder_part, [1, 0], 0) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_connecting_to_box) - # - # bottom_connecting_to_box = CylinderConnectingToBox(bottom_part, [1, 2], 1) - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_connecting_to_box) - # self.joint_shoulder_joint_to_cylinder_and_box(bottom_connecting_to_box, joining_box, bottom_part, [0, 2], 1) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_connecting_to_box) - # - # centre = [-6.580413981734434e-01, 5.756093176338770e-02, 2.797218065767146e+00] - # outer_point = [4.417e-01, 4.174e-02, 3.897e+00] - # - # p1 = [-1.12e+00, 9.29e-02, 3.22e+00] - # p2 = [-1.62e+00, 1.061e-01, 3.72e+00] - # p3 = [-2.12e+00, 1.14e-01, 4.26e+00] - # p4 = [-2.605e+00, 1.22e-01, 4.76e+00] - # d11 = vector.addVectors([p1, centre], [1, -1]) - # d21 = vector.addVectors([outer_point, centre], [1, -1]) - # d31 = vector.setMagnitude(vector.crossproduct3(d11, d21), -1.0) - - - # centralPath = ScaffoldPackage(MeshType_1d_path1, { - # 'scaffoldSettings': { - # 'Coordinate dimensions': 3, - # 'D2 derivatives': True, - # 'D3 derivatives': True, - # 'Length': 3.0, - # 'Number of elements': 4 - # }, - # 'meshEdits': exnodeStringFromNodeValues( - # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - # [[-6.58e-01, 5.75e-02, 2.797e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.12e+00, 9.29e-02, 3.22e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-1.62e+00, 1.061e-01, 3.72e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.12e+00, 1.14e-01, 4.26e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]], - # [[-2.605e+00, 1.22e-01, 4.76e+00], d11, d31, [0.0, 0.0, 0.0], d21, [0.0, 0.0, 0.0]] - # ]) - # }) - # - # cylinderCentralPath = CylinderCentralPath(self._region, centralPath, 5) - # - # cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - # - # base = CylinderEnds(4, 4, 0, 1, 1.0, - # centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], - # cylinderCentralPath.minorRadii[0]) - # torso_cylinder = CylinderMesh(fieldmodule, coordinates, 5, base, - # cylinderShape=cylinderShape, - # cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) - - # joining_torso = JoiningTorso([4, 4, 1]) - # self.join_to_torso(joining_torso, torso_cylinder._shield, shoulder_connecting_to_box, bottom_connecting_to_box) - # print(joining_torso.nodeId) - # self.generateElements(mesh, fieldmodule, coordinates, joining_torso) - # - # - # torso_part = torso_cylinder._shield - - -# -4.990e+00, -7.830e-01, 5.4884e+00 -# -# -# -# -6.480e+00, 1.118e-01, 3.8448e+00 -# -# -4.947e+00, 1.216e-01, 5.4829e+00 -# -# -6.004e+00, -6.005e-01, 3.3709e+00 -#-6.031e+00, 9.325e-02, 3.393e+00 - -# -6.496e+00, -5.925e-01, 3.8599e+00 - - # -6.031e+00, 9.325e-02, 3.393e+00 - - # nodeparams1 = [[torso_part.px[5][2][2], torso_part.px[5][2][0], torso_part.px[5][0][2], [[-c for c in torso_part.pd3[5][2][2]], torso_part.pd3[5][2][0]], - # [[-c for c in torso_part.pd1[5][2][2]], torso_part.pd3[5][0][2]]], - # [[-3.70e+00, 1.4e-01, 5.84e+00], [-4.762e+00, 1.11e-01, 3.95e+00], [-3.76e+00, -8.37e-01, 5.86e+00], [[-6.1e-01, 2.78e-02, -6.01e-01], [-1.35e-01, 2.04e-01, -8.587e-01]], - # [[-3.475e-02, -5.527e-01, 1.865e-02], [-2.697799339817220e-02, -6.167974824227329e-01, -9.214256788918185e-03]]]] - - # bottom_part2 = BaseLeg(self._elementsCount, nodeparams1) - # - # self.generateNodes(nodes, fieldmodule, coordinates, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, bottom_part2) - # - # # nodeparams2 = [[[-4.990e+00, -7.830e-01, 5.4884e+00], bottom_part2.px[2][2][0], [-4.947e+00, 1.216e-01, 5.4829e+00], [[-7.288e-03, 4.34e-01, 1.23e-03], bottom_part2.pd3[2][2][0]], - # # [[6.23e-01, 1.96e-03, -5.323e-01], [6.23e-01, 1.96e-03, -5.323e-01]]], - # # [[-6.480e+00, 1.118e-01, 3.8448e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.496e+00, -5.925e-01, 3.8599e+00], [[3.627e-01, 1.095e-02, -3.904e-01], [3.627e-01, 1.095e-02, -3.904e-01]], - # # [[2.557e-02, -5.3e-01, -1.8599e-02], [2.557e-02, -5.3e-01, -1.8599e-02]]]] - # - # nodeparams2 = [[[-4.7641e+00, 1.113e-01, 3.946e+00], bottom_part2.px[2][2][0], [-4.995e+00, -7.875e-01, 5.487e+0], [[1.353e-01, -2.048e-01, 8.587e-01], bottom_part2.pd3[2][2][0]], - # [[5.204e-03, 7.672e-01, -1.017e-03], [5.204e-03, 7.672e-01, -1.017e-03]]], - # [[-6.496e+00, -5.925e-01, 3.859e+00], [-6.031e+00, 9.325e-02, 3.393e+00], [-6.476e+00, 1.073e-01, 3.835e+00], [[-1.6976e-02, 3.5188e-01, 1.2348e-02], [-1.6976e-02, 3.5188e-01, 1.2348e-02]], - # [[3.589e-01, 1.082e-02, -3.863e-01], [3.589e-01, 1.082e-02, -3.863e-01]]]] - # - # shoulder_part2 = BaseLeg(self._elementsCount, nodeparams2) - # shoulder_part2._shoulder = True - # - # self.remove_duplicate_nodes_from_shoulder(shoulder_part2) - # self.generateNodes(nodes, fieldmodule, coordinates, shoulder_part2) - # self.join_shoulder_to_bottom_part(shoulder_part2, bottom_part2) - # self.generateElements(mesh, fieldmodule, coordinates, shoulder_part2) - # - # joining_box = JoiningBox([1, 4, 1]) - # self.generateNodes(nodes, fieldmodule, coordinates, joining_box) - # self.join_box_to_bottom_and_shoulder(joining_box, bottom_part, shoulder_part) - # self.generateElements(mesh, fieldmodule, coordinates, joining_box) - - - - - # elementsCount = [2, 2, 5] - # self.px = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd1 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd2 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.pd3 = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.nodeId = [[[None] * (elementsCount[0] + 2) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - # self.elementId = [[[None] * (elementsCount[0]+1) for c in range(elementsCount[1])] for c in range(elementsCount[2])] - # - # nodeparams1 = [[[0.0, 0.0, 0.0], [0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [1/self._elementsCount[0], 0.0, 0.0]]], - # [[0.0, 0.0, 1.4], [0.0, -1.0, 1.4], [1.2, 0.0, 1.0],[[0.0, -1/self._elementsCount[1], 0.0], [0.0, -1/self._elementsCount[1], 0.0]], - # [[1/self._elementsCount[0], 0.0, 0.0], [0.5*0.7071, 0.0, -0.5*0.7071]]]] - # - # nodeparams2 = [[[0.5, 0.0, 2.2], [0.5, -1.0, 2.2], [1.2, 0.0, 1.0],[[0.0, -1 / self._elementsCount[1], 0.0], [0.0, -1 / self._elementsCount[1], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]]], - # [[1.7, 0.0, 2.2], [1.7, -1.0, 2.2], [1.7, 0.0, 1.2], [[0.0, -1 / self._elementsCount[0], 0.0], [0.0, -1 / self._elementsCount[0], 0.0]], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]],]] - # - # - # baseleg1 = BaseLeg(self._elementsCount, nodeparams1) - # self.copyBaseLeg2Bifurcation(baseleg1, 1) - # - # # self.px[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 1.0, 2.2] - # # self.px[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.5, 2.2] - # # self.px[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 2.2] - # # self.pd1[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd1[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, -0.5, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd2[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.5, 0.0, 0.0] - # # self.pd3[self._elementsCount[2]//2+1][0][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][1][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # # self.pd3[self._elementsCount[2]//2+1][2][self._elementsCount[0] + 1] = [0.0, 0.0, 0.7] - # - # baseleg2 = BaseLeg(self._elementsCount, nodeparams2) - # self.copyBaseLeg2Bifurcation(baseleg2, 2) - - # self.generateBaseLeg(fieldModule, coordinates, mesh, nodes) - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - - def _get_node_params(self): - """ - - :return: - """ - x_bottom_base_centre = [0.0, 0.0, 0.0] - x_bottom_base_curve1w = [self.torso_radius, 0.0, 0.0] - x_bottom_base_curve1e = [-self.torso_radius, 0.0, 0.0] - x_bottom_base_curve2 = [0.0, self.torso_radius, 0.0] - d1_bottom_base_curve1 = [[self.torso_radius/self._elementsCount[0], 0.0, 0.0], - [self.torso_radius/self._elementsCount[0], 0.0, 0.0], - [self.torso_radius/self._elementsCount[0], 0.0, 0.0]] - d1_bottom_base_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - x_bottom_end_centre = [0.0, 0.0, 1.4] - x_bottom_end_curve1w = [1.2, 0.0, 1.0] - x_bottom_end_curve1e = [-1.2, 0.0, 1.0] - x_bottom_end_curve2 = [0.0, 1.0, 1.4] - d1_bottom_end_curve1 = [[0.5*0.7071, 0.0, 0.5*0.7071], - [1/self._elementsCount[0], 0.0, 0.0], - [0.5*0.7071, 0.0, -0.5*0.7071]] - d1_bottom_end_curve2 = [[0.0, 1/self._elementsCount[1], 0.0], - [0.0, 1/self._elementsCount[1], 0.0]] - - nodeparams1 = [[x_bottom_base_curve1e, x_bottom_base_centre, x_bottom_base_curve1w, x_bottom_base_curve2, d1_bottom_base_curve1, - d1_bottom_base_curve2], - [x_bottom_end_curve1e, x_bottom_end_centre, x_bottom_end_curve1w, x_bottom_end_curve2, d1_bottom_end_curve1, - d1_bottom_end_curve2]] - - # x_shoulder_base_centre = [0.75, 0.0, self.shoulder_height] - # x_shoulder_base_curve1 = [1.2, 0.0, 1.0] - # x_shoulder_base_curve2 = [0.75, 1.0, self.shoulder_height] - # d1_shoulder_base_curve1 = [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]] - # d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - x_shoulder_base_centre = self.shoulder_joint - x_shoulder_base_curve1w = self.armpit - x_shoulder_base_curve1e = self.shoulder_point - x_shoulder_base_curve2 = [self.shoulder_joint[0], 1.0, self.shoulder_joint[2]] - derivw = vector.addVectors([x_shoulder_base_curve1w, x_shoulder_base_centre], [1, -1]) - derive = vector.addVectors([x_shoulder_base_centre, x_shoulder_base_curve1e], [1, -1]) - derivc = vector.addVectors([derivw, derive], [1, 1]) - derivc = vector.scaleVector(derivc, 0.5) - d1_shoulder_base_curve1 = [derive, derivc, derivw] - d1_shoulder_base_curve2 = [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]] - kv = [0.0, 1.0, 0.0] - cv = [self.right_arm_length, 0.0, 0.0] - cev = vector.rotateVectorAroundVector(cv, kv, self.right_arm_angle) - # ce = vector.addVectors([cev, [0.0, 0.0, self.shoulder_height]], [1, 1]) - ce = vector.addVectors([cev, self.shoulder_joint], [1, 1]) - x_shoulder_end_centre = ce - # x_shoulder_end_curve1 = [1.7, 0.0, self.shoulder_height - self.left_arm_radius] - x_shoulder_end_curve1w = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), self.right_arm_radius)], [1, 1]) - x_shoulder_end_curve1e = vector.addVectors([ce, vector.setMagnitude(vector.crossproduct3(kv, cev), -self.right_arm_radius)], [1, 1]) - # x_shoulder_end_curve2 = [1.7, self.left_arm_radius, self.shoulder_height] - x_shoulder_end_curve2 = vector.addVectors([ce, vector.setMagnitude(kv, self.right_arm_radius)], [1, 1]) - d1_shoulder_end_curve1 = [[0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]], [0.0, 0.0, -self.left_arm_radius / self._elementsCount[1]]] - d1_shoulder_end_curve2 = [[0.0, self.left_arm_radius / self._elementsCount[0], 0.0], [0.0, self.left_arm_radius / self._elementsCount[0], 0.0]] - - nodeparams2 = [[x_shoulder_base_curve1e, x_shoulder_base_centre, x_shoulder_base_curve1w, x_shoulder_base_curve2, d1_shoulder_base_curve1, - d1_shoulder_base_curve2], - [x_shoulder_end_curve1e, x_shoulder_end_centre, x_shoulder_end_curve1w, x_shoulder_end_curve2, d1_shoulder_end_curve1, - d1_shoulder_end_curve2]] - - return nodeparams1, nodeparams2 - - def join_to_torso(self, joining_torso, torso, shoulder_joint, bottom_joint): - """ - - :param joining_torso: - :param shoulder_part: - :param bottom_part: - :return: - """ - for n2 in range(joining_torso._elementsCount[1] + 1): - for n1 in range(joining_torso._elementsCount[1] + 1): - joining_torso.nodeId[1][n2][n1] = torso.nodeId[0][n2][4 - n1] - joining_torso.px[1][n2][n1] = torso.px[0][n2][4 - n1] - joining_torso.pd1[1][n2][n1] = torso.pd1[0][n2][4 - n1] - joining_torso.pd2[1][n2][n1] = torso.pd2[0][n2][4 - n1] - joining_torso.pd3[1][n2][n1] = torso.pd3[0][n2][4 - n1] - - if n1 <= joining_torso._elementsCount[0]//2: - joining_torso.nodeId[0][n2][n1] = shoulder_joint.nodeId[0][n2][joining_torso._elementsCount[0] - n1] - joining_torso.px[0][n2][n1] = shoulder_joint.px[0][n2][joining_torso._elementsCount[0] - n1] - joining_torso.pd1[0][n2][n1] = shoulder_joint.pd1[0][n2][joining_torso._elementsCount[0] - n1] - joining_torso.pd2[0][n2][n1] = shoulder_joint.pd2[0][n2][joining_torso._elementsCount[0] - n1] - joining_torso.pd3[0][n2][n1] = shoulder_joint.pd3[0][n2][joining_torso._elementsCount[0] - n1] - else: - joining_torso.nodeId[0][n2][n1] = bottom_joint.nodeId[1][n2][n1] - joining_torso.px[0][n2][n1] = bottom_joint.px[1][n2][n1] - joining_torso.pd1[0][n2][n1] = bottom_joint.pd1[1][n2][n1] - joining_torso.pd2[0][n2][n1] = bottom_joint.pd2[1][n2][n1] - joining_torso.pd3[0][n2][n1] = bottom_joint.pd3[1][n2][n1] - - def joint_shoulder_joint_to_cylinder_and_box(self, shoulder_connecting_to_box, joining_box, cylinder_part, cidxs, bidx): - """ - - :param shoulder_connecting_to_box: - :param joining_box: - :param shoulder_part: - :return: - """ - for n2 in range(shoulder_connecting_to_box._elementsCount[1] + 1): - for n1 in range(shoulder_connecting_to_box._elementsCount[0]//2, shoulder_connecting_to_box._elementsCount[0] + 1): - shoulder_connecting_to_box.nodeId[cidxs[0]][n2][n1] = cylinder_part.nodeId[cidxs[1]][n2][n1] - shoulder_connecting_to_box.px[cidxs[0]][n2][n1] = cylinder_part.px[cidxs[1]][n2][n1] - shoulder_connecting_to_box.pd1[cidxs[0]][n2][n1] = cylinder_part.pd1[cidxs[1]][n2][n1] - shoulder_connecting_to_box.pd2[cidxs[0]][n2][n1] = cylinder_part.pd2[cidxs[1]][n2][n1] - shoulder_connecting_to_box.pd3[cidxs[0]][n2][n1] = cylinder_part.pd3[cidxs[1]][n2][n1] - - shoulder_connecting_to_box.nodeId[bidx][n2][2] = joining_box.nodeId[1][n2][1] - shoulder_connecting_to_box.px[bidx][n2][2] = joining_box.px[1][n2][1] - shoulder_connecting_to_box.pd1[bidx][n2][2] = joining_box.pd1[1][n2][1] - shoulder_connecting_to_box.pd2[bidx][n2][2] = joining_box.pd2[1][n2][1] - shoulder_connecting_to_box.pd3[bidx][n2][2] = joining_box.pd3[1][n2][1] - - def join_box_to_bottom_and_shoulder(self, joining_box, bottom_part, shoulder_part): - """ - - :param bottom_part: - :param shoulder_part: - :return: - """ - - for n2 in range(bottom_part._elementsCount[1] + 1): - for n1 in range(2): - joining_box.nodeId[0][n2][n1] = bottom_part.nodeId[bottom_part._elementsCount[2]][n2][n1 + 1] - joining_box.px[0][n2][n1] = bottom_part.px[bottom_part._elementsCount[2]][n2][n1 + 1] - joining_box.pd1[0][n2][n1] = bottom_part.pd1[bottom_part._elementsCount[2]][n2][n1 + 1] - joining_box.pd2[0][n2][n1] = bottom_part.pd2[bottom_part._elementsCount[2]][n2][n1 + 1] - joining_box.pd3[0][n2][n1] = bottom_part.pd3[bottom_part._elementsCount[2]][n2][n1 + 1] - joining_box.nodeId[1][n2][0] = shoulder_part.nodeId[0][n2][2] - joining_box.px[1][n2][0] = shoulder_part.px[0][n2][2] - joining_box.pd1[1][n2][0] = shoulder_part.pd1[0][n2][2] - joining_box.pd2[1][n2][0] = shoulder_part.pd2[0][n2][2] - joining_box.pd3[1][n2][0] = shoulder_part.pd3[0][n2][2] - - def remove_duplicate_nodes_from_shoulder(self, shoulder_part, c=0): - """ - - :param shoulder_part: - :param bottom_part: - :return: - """ - def condition(n2, n1): - if c: - return n2 == 0 or n2 == 1 - else: - return n1 == 0 or n1 == 1 - - for n3 in range(1): - for n2 in range(shoulder_part._elementsCount[0] + 1): - for n1 in range(shoulder_part._elementsCount[1] + 1): - if condition(n2, n1): - shoulder_part.px[n3][n2][n1] = None - shoulder_part.pd1[n3][n2][n1] = None - shoulder_part.pd2[n3][n2][n1] = None - shoulder_part.pd3[n3][n2][n1] = None - - - def join_shoulder_to_bottom_part(self, shoulder_part, bottom_part, c=0): - """ - - :param shoulder_part: - :param bottom_part: - :return: - """ - def condition(n2, n1): - # if c: - # n2, n1 = n1, n2 - # return (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or\ - # (n2 == 2 and n1 == 1) or (n2 == 3 and n1 == 1) or (n2 == 4 and n1 == 1) - if c: - return n2 == 0 or n2 == 1 - else: - return n1 == 0 or n1 == 1 - - def index(n2, n1): - if c: - if n2 == 0 and n1 == 1: - return n1 - 1, 4 - n2 - 1 - if n2 == 0 and n1 == 3: - return n1 + 1, 4 - n2 - 1 - else: - return n1, 4 - n2 - else: - return n2, n1 - - for n3 in range(1): - for n2 in range(shoulder_part._elementsCount[0] + 1): - for n1 in range(shoulder_part._elementsCount[1] + 1): - if condition(n2, n1): - n2b, n1b = index(n2, n1) - n3b = bottom_part._elementsCount[2] - shoulder_part.nodeId[n3][n2][n1] = bottom_part.nodeId[n3b][n2b][n1b] - shoulder_part.px[n3][n2][n1] = bottom_part.px[n3b][n2b][n1b] - shoulder_part.pd1[n3][n2][n1] = bottom_part.pd1[n3b][n2b][n1b] - shoulder_part.pd2[n3][n2][n1] = bottom_part.pd2[n3b][n2b][n1b] - shoulder_part.pd3[n3][n2][n1] = bottom_part.pd3[n3b][n2b][n1b] - - # def copyBaseLeg2Bifurcation(self, baseleg, idx): - # """ - # - # :return: - # """ - # for n3 in range(self._elementsCount[2]//2 + 1): - # for n2 in range(self._elementsCount[0] + 1): - # for n1 in range(self._elementsCount[1] + 1): - # if idx == 1: - # n3s = n3 - # elif idx == 2: - # n3s = self._elementsCount[2]//2 + 2 + n3 - # self.px[n3s][n2][n1] = baseleg.px[n3][n2][n1] - # self.pd1[n3s][n2][n1] = baseleg.pd1[n3][n2][n1] - # self.pd2[n3s][n2][n1] = baseleg.pd2[n3][n2][n1] - # self.pd3[n3s][n2][n1] = baseleg.pd3[n3][n2][n1] - # if idx == 2 and n3 == 0: - # if (n2 == 0 and n1 == 1) or (n2 == 1 and n1 == 1) or (n2 == 2 and n1 == 0) or (n2 == 2 and n1 == 1): - # self.px[n3s][n2][n1] = None - # self.pd1[n3s][n2][n1] = None - # self.pd2[n3s][n2][n1] = None - # self.pd3[n3s][n2][n1] = None - - def generateNodes(self, nodes, fieldModule, coordinates, part_structure): - """ - Create cylinder nodes from coordinates. - :param nodes: nodes from coordinates. - :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. - :param coordinates: Coordinate field to define. - """ - nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) - self._startNodeIdentifier = nodeIdentifier - nodeIdentifier = self.topologygenerateNodes(fieldModule, coordinates, nodeIdentifier, part_structure) - self._endNodeIdentifier = nodeIdentifier - - def generateElements(self, mesh, fieldModule, coordinates, part_structure): - """ - Create cylinder elements from nodes. - :param mesh: - :param fieldModule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. - :param coordinates: Coordinate field to define. - """ - elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) - self._startElementIdentifier = elementIdentifier - elementIdentifier = self.topologygenerateElements(fieldModule, coordinates, elementIdentifier, part_structure, []) - self._endElementIdentifier = elementIdentifier - - def topologygenerateNodes(self, fieldmodule, coordinates, startNodeIdentifier, part_structure): - """ - Create shield nodes from coordinates. - """ - nodeIdentifier = startNodeIdentifier - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - nodetemplate = nodes.createNodetemplate() - nodetemplate.defineField(coordinates) - nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_VALUE, 1) - nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) - nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS2, 1) - nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS3, 1) - nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D2_DS1DS2, 1) - cache = fieldmodule.createFieldcache() - - for n3 in range(part_structure._elementsCount[2] + 1): - for n2 in range(part_structure._elementsCount[1] + 1): - for n1 in range(part_structure._elementsCount[0] + 1): - if part_structure.px[n3][n2][n1]: - node = nodes.createNode(nodeIdentifier, nodetemplate) - part_structure.nodeId[n3][n2][n1] = nodeIdentifier - cache.setNode(node) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_VALUE, 1, part_structure.px [n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS1, 1, part_structure.pd1[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS2, 1, part_structure.pd2[n3][n2][n1]) - coordinates.setNodeParameters(cache, -1, Node.VALUE_LABEL_D_DS3, 1, part_structure.pd3[n3][n2][n1]) - nodeIdentifier += 1 - - return nodeIdentifier - - def topologygenerateElements(self, fieldmodule, coordinates, startElementIdentifier, part_structure, 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 meshGroups: Zinc mesh groups to add elements to. - :return: next elementIdentifier. - """ - elementIdentifier = startElementIdentifier - useCrossDerivatives = False - mesh = fieldmodule.findMeshByDimension(3) - - tricubichermite = eftfactory_tricubichermite(mesh, useCrossDerivatives) - eft = tricubichermite.createEftNoCrossDerivatives() - elementtemplate = mesh.createElementtemplate() - elementtemplate.setElementShapeType(Element.SHAPE_TYPE_CUBE) - elementtemplate.defineField(coordinates, -1, eft) - - elementtemplate1 = mesh.createElementtemplate() - elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) - - # isEven = (self.elementsCountAcross % 2) == 0 - e1a = 0 - e1b = e1a + 1 - e1z = part_structure._elementsCount[0] - 1 - e1y = e1z - 1 - e2a = 0 - e2b = e2a + 1 - e2c = e2a + 2 - e2z = part_structure._elementsCount[1]-1 - e2y = e2z - 1 - # e2x = e2z - 2 - for e3 in range(part_structure._elementsCount[2]): - for e2 in range(part_structure._elementsCount[1]): - for e1 in range(part_structure._elementsCount[0]): - eft1 = eft - scalefactors = None - # if e3 >= 3: - # e3t = e3 + 1 - # else: - # e3t = e3 - # nids = [ part_structure.nodeId[e3t][e2][e1], part_structure.nodeId[e3t][e2 + 1][e1], - # part_structure.nodeId[e3t+1][e2][e1], part_structure.nodeId[e3t+1][e2 + 1][e1], - # part_structure.nodeId[e3t][e2][e1 + 1], part_structure.nodeId[e3t][e2 + 1][e1 + 1], - # part_structure.nodeId[e3t+1][e2][e1 + 1], part_structure.nodeId[e3t+1][e2 + 1][e1 + 1] ] - nids = [ part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2 + 1][e1], - part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], - part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3][e2 + 1][e1 + 1], - part_structure.nodeId[e3+1][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1] ] - - if isinstance(part_structure, JoiningBox): - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - if e2 == e2a or e2 == e2z: - if e2 == e2a: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) - elif e2 == e2z: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [6], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [])]) - else: - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - else: - if (e2 < e2b) or (e2 > e2y): - if (e1 < e1b) or (e1 > e1y): - continue # no element due to triple point closure - if (e2 < e2a) or (e2 > e2z): - if e2 < e2a: - nids = [part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], - part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], part_structure.nodeId[e3+1][e2][e1+1]] - elif e2 > e2z: - nids = [part_structure.nodeId[e3][e2][e1+1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2][e1+1], part_structure.nodeId[e3+1][e2][e1], - part_structure.nodeId[e3][e2+1][e1+1], part_structure.nodeId[e3][e2+1][e1], part_structure.nodeId[e3+1][e2+1][e1+1], part_structure.nodeId[e3+1][e2+1][e1]] - elif (e2 == e2a) or (e2 == e2z): - # bottom and top row elements - if e2 == e2a: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - # if e3 == part_structure._elementsCount[2] // 2 + 1 and e1 == e1b: - # e3r = e3t-1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - - # if e3 == 2: - # remapEftNodeValueLabel(eft1, [3, 5], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # elif e3 == 3: - # if e1 == e1b: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - if isinstance(part_structure, BaseLeg2): - if part_structure._shoulder: - if e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [])]) - # else: - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - - # else: - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS3, [1])]) - # remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS3, [1])]) - remapEftNodeValueLabel(eft1, [1, 3, 5, 7], Node.VALUE_LABEL_D_DS3, - [(Node.VALUE_LABEL_D_DS1, [])]) - if (e1 == e1b) or (e1 == e1y): - # map bottom triple point element - if e1 == e1b: - # if e3 != 2: - # remapEftNodeValueLabel(eft1, [ 2, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS1, - [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - else: - remapEftNodeValueLabel(eft1, [6, 8], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - elif e2 == e2z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if isinstance(part_structure, BaseLeg2): - if part_structure._shoulder and e3 == 0 and e1 == e1b: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) - else: - remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1])]) - remapEftNodeValueLabel(eft1, [2, 4, 6, 8], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS3, [])]) - if (e1 == e1b) or (e1 == e1y): - # map top triple point element - if e1 == e1b: - remapEftNodeValueLabel(eft1, [1, 3], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [1])]) - else: - remapEftNodeValueLabel(eft1, [5, 7], Node.VALUE_LABEL_D_DS1,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS3, [])]) - - elif (e2 == e2b) or (e2 == e2y): - if (e1 <= e1a) or (e1 >= e1z): - if e1 < e1a: - e2r = e1 - if e2 == e2b: - nids = [part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3+1][e2c][e1+1], part_structure.nodeId[e3+1][e2r+1][e1b], - part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3+1][e2c][e1], part_structure.nodeId[e3+1][e2r][e1b]] - if e2 == e2y: - e2r = 2*part_structure._elementsCount[1] - e1-1 - nids = [part_structure.nodeId[e3][e2r][e1b], part_structure.nodeId[e3][e2y][e1+1], part_structure.nodeId[e3+1][e2r][e1b], part_structure.nodeId[e3+1][e2y][e1+1], - part_structure.nodeId[e3][e2r+1][e1b], part_structure.nodeId[e3][e2y][e1], part_structure.nodeId[e3+1][e2r+1][e1b], part_structure.nodeId[e3+1][e2y][e1]] - elif e1 == e1a: - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - if e2 == e2b: - if e3 == part_structure._elementsCount[2] // 2 + 1: - e3r = e3-1 # to join upper leg with the lower leg. - nids[0] = part_structure.nodeId[e3r][e2a][e1b] - nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - nids[4] = part_structure.nodeId[e3r][e2][e1 + 1] - nids[5] = part_structure.nodeId[e3r][e2 + 1][e1 + 1] - else: - nids[0] = part_structure.nodeId[e3][e2a][e1b] - nids[2] = part_structure.nodeId[e3+1][e2a][e1b] - tripleN = [5, 7] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - elif e2 == e2y: - nids[1] = part_structure.nodeId[e3][e2z+1][e1b] - nids[3] = part_structure.nodeId[e3+1][e2z+1][e1b] - tripleN = [6, 8] - remapEftNodeValueLabel(eft1, tripleN, Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS3, [])]) - 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 e1 == e1z: - eft1 = tricubichermite.createEftNoCrossDerivatives() - if e2 == e2b: - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] - nids[4] = part_structure.nodeId[e3][e2a][e1z] - nids[6] = part_structure.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] = part_structure.nodeId[e3][e2z+1][e1z] - nids[7] = part_structure.nodeId[e3+1][e2z+1][e1z] - remapEftNodeValueLabel(eft1, [2, 4], Node.VALUE_LABEL_D_DS3,[(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - elif e1 > e1z: - e2r = part_structure._elementsCount[0] - e1 - if e2 == e2b: - nids = [part_structure.nodeId[e3][e2r][e1z], part_structure.nodeId[e3][e2c][e1], part_structure.nodeId[e3+1][e2r][e1z], part_structure.nodeId[e3+1][e2c][e1], - part_structure.nodeId[e3][e2r-1][e1z], part_structure.nodeId[e3][e2c][e1+1], part_structure.nodeId[e3+1][e2r-1][e1z], part_structure.nodeId[e3+1][e2c][e1+1]] - elif e2 == e2y: - e2r = e2z+e1-e1z - nids[1] = part_structure.nodeId[e3][e2r][e1z] - nids[3] = part_structure.nodeId[e3+1][e2r][e1z] - nids[5] = part_structure.nodeId[e3][e2r+1][e1z] - nids[7] = part_structure.nodeId[e3+1][e2r+1][e1z] - elif e1 == e1b: - if e2 == e2b: - eft1 = tricubichermite.createEftNoCrossDerivatives() - # if e3 == part_structure._elementsCount[2] // 2 + 1: - # e3r = e3 - 1 - # nids[0] = part_structure.nodeId[e3r][e2][e1] - # nids[1] = part_structure.nodeId[e3r][e2 + 1][e1] - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # if e3 == 2: - # setEftScaleFactorIds(eft1, [1], []) - # scalefactors = [-1.0] - # remapEftNodeValueLabel(eft1, [1, 2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # # remapEftNodeValueLabel(eft1, [3, 4], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) - - - - - - else: - if e1 < e1a: - nids = [ part_structure.nodeId[e3][e2 + 1][e1 + 1], part_structure.nodeId[e3][e2][e1 + 1], part_structure.nodeId[e3+1][e2 + 1][e1 + 1], part_structure.nodeId[e3+1][e2][e1 + 1], - part_structure.nodeId[e3][e2 + 1][e1], part_structure.nodeId[e3][e2][e1], part_structure.nodeId[e3+1][e2 + 1][e1], part_structure.nodeId[e3+1][e2][e1]] - elif e1 == e1a: - # map left column elements - eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] - 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])]) - - # if e3 == 2: - # if e1 == e1b: - # # joining elements - # if e2 == 0: - # nids = [15, 17, 22, 24, 16, 18, 23, 25] - # remapEftNodeValueLabel(eft1, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS1, - # [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [2], Node.VALUE_LABEL_D_DS2, - # [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) - # - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS3, - # [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [4], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) - # remapEftNodeValueLabel(eft1, [7, 8], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - # remapEftNodeValueLabel(eft1, [7], Node.VALUE_LABEL_D2_DS1DS2, [(Node.VALUE_LABEL_D_DS3, [])]) - - - - - - # elif e2 == 1: - # nids = [17, 20, 24, 26, 18, 21, 25, 27] - - if not all(nids): - continue - - if eft1 is not eft: - elementtemplate1.defineField(coordinates, -1, eft1) - element = mesh.createElement(elementIdentifier, elementtemplate1) - else: - element = mesh.createElement(elementIdentifier, elementtemplate) - result2 = element.setNodesByIdentifier(eft1, nids) - if scalefactors: - result3 = element.setScaleFactors(eft1, scalefactors) - else: - result3 = 7 - #print('create element shield', elementIdentifier, result2, result3, nids) - part_structure.elementId[e3][e2][e1] = elementIdentifier - elementIdentifier += 1 - - for meshGroup in meshGroups: - meshGroup.addElement(element) - - return elementIdentifier - - -class BaseLeg: - """ - Base case for creating a child - """ - def __init__(self, elementsCount, nodeparams): - """ - - :param fieldmodule: - :param coordinates: - :param mesh: - :param nodes: - """ - elementsCount = [4, 4, 2] - self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] - self.nodeparams = nodeparams - self._shoulder = False - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - self.generateBaseLeg(nodeparams) - - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) - plane = [n[0], n[1], n[2], d] - mirror = Mirror(plane) - for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): - for n3 in range(elementsCount[2]+1): - for n1 in range(elementsCount[0]//2+1): - n3q = n3 - n2q = elementsCount[1] - n2 - n1q = n1 - if self.px[n3q][n2q][n1q]: - self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) - self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) - self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) - self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - - n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) - plane = [n[0], n[1], n[2], d] - mirror = Mirror(plane) - for n2 in range(elementsCount[1]+1): - for n3 in range(elementsCount[2]+1): - for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): - n3q = n3 - n2q = n2 - n1q = elementsCount[0] - n1 - if self.px[n3q][n2q][n1q]: - self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) - if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: - self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) - self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - else: - self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) - self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) - self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) - self._elementsCount = elementsCount - - def generateBaseLeg(self, nodeparams): - """ - Generate base leg that is a cylinder generated from cylinder ends. - :return: - """ - bottomnodeparams = nodeparams[0] - topnodeparams = nodeparams[1] - self.genetateBottomSurface(bottomnodeparams) - self.generateTopSurface(topnodeparams) - self.generateMiddleLevels() - self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateMiddleLevels() - # self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - def genetateBottomSurface(self, bottomnodeparams): - """ - Use major and minor curves to generate the ellipse - :return: - """ - centre, xec1, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, 0) - - def generateTopSurface(self, topnodeparams): - """ - - :return: - """ - centre, xec1, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4] - txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) - - def generateMiddleLevels(self): - """ - - :return: - """ - btx = self.px - btd1 = self.pd1 - btd2 = self.pd2 - btd3 = self.pd3 - # generate the armpit curves. - elementsCountOut = 2 - txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][self._elementsCount[0]], - btx[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [btd2[0][self._elementsCount[1]][self._elementsCount[0]], - btd2[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - elementsCountOut) - txec1, td1ec1, pec1, pxic1, psfc1 = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]][0], btx[self._elementsCount[2]][self._elementsCount[1]][0]], - [btd2[0][self._elementsCount[1]][0], btd2[self._elementsCount[2]][self._elementsCount[1]][0]], - elementsCountOut) - txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]], btx[self._elementsCount[2]][0][self._elementsCount[0]]], - [btd2[0][0][self._elementsCount[0]], btd2[self._elementsCount[2]][0][self._elementsCount[0]]], - elementsCountOut) - - tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][self._elementsCount[0]], - btd3[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]][self._elementsCount[0]], - btd1[self._elementsCount[2]][self._elementsCount[1]][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlec1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]][0], - btd3[self._elementsCount[2]][self._elementsCount[1]][0]], - [[0.0, 0.0, 0.0]] * 2, pec1, pxic1, psfc1)[0] - tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]], - btd3[self._elementsCount[2]][0][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] - - for n3 in range(1, self._elementsCount[2]): - centre = txcc1[n3] - txc1, td1c1 = self.generate1DPath([centre, txec1[n3]], [[-c for c in tdlcc1[n3]], tdlec1[n3]], self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, n3) - - def smoothd2(self): - """ - - :return: - """ - btx = self.px - btd1 = self.pd1 - btd2 = self.pd2 - btd3 = self.pd3 - # smooth d2 - for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 1): - if btx[0][n2][n1]: - nx = [] - nd1 = [] - for n3 in range(self._elementsCount[2] + 1): - nx.append(btx[n3][n2][n1]) - nd1.append(btd2[n3][n2][n1]) - td2 = smoothCubicHermiteDerivativesLine(nx, nd1) - for n3 in range(self._elementsCount[2] + 1): - btd2[n3][n2][n1] = td2[n3] - - def generate1DPath(self, nx, nd1, elementsCountOut): - """ - Given end nodes generate 1d path - :return: - """ - tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut) - return tx, td1 - - def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): - """ - Get major and minor curves to generate the rounded surface. - :return: - """ - - # self._coreMinorRadii.append( - # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) - # self._coreMajorRadii.append( - # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) - - # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 - # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] - # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] - majorAxis = [c*self._elementsCount[0] for c in td1c2[0]] - minorAxis = [-c*self._elementsCount[1] for c in td1c1[0]] - elementsCountAcrossShell = 0 - elementsCountAcrossTransition = 1 - shellProportion = 1.0 - coreMajorRadius = 1.0 - coreMinorRadius = 1.0 - elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 - ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - - shield = ellipse.getShield() - ellipse.generateBase1DMesh(0) - - ellipse.px[self._elementsCount[1]][0] = txc1[-1] - ellipse.pd3[self._elementsCount[1]][0] = td1c1[-1] - ellipse.px[0][self._elementsCount[0]] = txc2[-1] - ellipse.pd3[0][self._elementsCount[0]] = td1c2[-1] - - nx = [] - nd1 = [] - for n in range(elementsCountAround + 1): - n1, n2 = shield.convertRimIndex(n) - xi = n/elementsCountAround - # ellipse.px[n2][n1][2] = (1 - xi) * ellipse.px[self._elementsCount[1]][0][2] + xi * \ - # ellipse.px[0][self._elementsCount[0]][2] - x_p = vector.addVectors([vector.scaleVector(ellipse.px[self._elementsCount[1]][0], 1 - xi), - vector.scaleVector(ellipse.px[0][self._elementsCount[0]], xi)], [1, 1]) - delta = [-ellipse.px[0][self._elementsCount[0]][c] + ellipse.px[self._elementsCount[1]][0][c] for c in range(3)] - normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) - delta_p = vector.addVectors([x_p, ellipse.px[self._elementsCount[1]][self._elementsCount[0]]], [1, -1]) - delta_p_normalmag = vector.dotproduct(delta_p, normal) - delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) - delnormag = vector.dotproduct(delta, normal) - delnor = vector.scaleVector(normal, delnormag) - if 0 0), 'createCylinderMesh3d: Invalid number of along elements' - # assert (self._elementsCountAcrossMinor > 3), 'createCylinderMesh3d: Invalid number of across elements' - # assert (self._elementsCountAcrossMinor % 2 == 0), 'createCylinderMesh3d: number of across elements' \ - # ' is not an even number' - # assert (self._elementsCountAcrossMajor > 1), 'createCylinderMesh3d: Invalid number of up elements' - # assert (self._cylinderShape in [self._cylinderShape.CYLINDER_SHAPE_FULL, - # self._cylinderShape.CYLINDER_SHAPE_LOWER_HALF]), \ - # 'createCylinderMesh3d: Invalid cylinder mode.' - nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - mesh = fieldmodule.findMeshByDimension(3) - - -class CrotchEllipses: - def __init__(self): - """ - - """ - - -class BaseLeg2: - """ - Base case for creating a child - """ - def __init__(self, elementsCount, nodeparams): - """ - - :param fieldmodule: - :param coordinates: - :param mesh: - :param nodes: - """ - # elementsCount = [4, 4, 3] - # self._elementsCount = [elementsCount[0]//2, elementsCount[1]//2, elementsCount[2]] - self._elementsCount = [elementsCount[0], elementsCount[1], elementsCount[2]] - self.nodeparams = nodeparams - self._shoulder = False - - self.px = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd1 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd2 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.pd3 = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.nodeId = [[[None] * (elementsCount[0] + 1) for c in range(elementsCount[1] + 1)] for c in range(elementsCount[2] + 1)] - self.elementId = [[[None] * elementsCount[0] for c in range(elementsCount[1])] for c in range(elementsCount[2])] - self.generateBaseLeg(nodeparams) - - # n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][1], nodeparams[1][0]) - # plane = [n[0], n[1], n[2], d] - # mirror = Mirror(plane) - # for n2 in range(elementsCount[1]//2+1, elementsCount[1]+1): - # for n3 in range(elementsCount[2]+1): - # for n1 in range(elementsCount[0]//2+1): - # n3q = n3 - # n2q = elementsCount[1] - n2 - # n1q = n1 - # if self.px[n3q][n2q][n1q]: - # self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) - # self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) - # self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) - # self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - # - # n, d = geometry.get_plane_normal_vector_and_distance(nodeparams[0][0], nodeparams[0][2], nodeparams[1][0]) - # plane = [n[0], n[1], n[2], d] - # mirror = Mirror(plane) - # for n2 in range(elementsCount[1]+1): - # for n3 in range(elementsCount[2]+1): - # for n1 in range(elementsCount[0]//2+1, elementsCount[0]+1): - # n3q = n3 - # n2q = n2 - # n1q = elementsCount[0] - n1 - # if self.px[n3q][n2q][n1q]: - # self.px[n3][n2][n1] = mirror.mirrorImageOfPoint(self.px[n3q][n2q][n1q]) - # if n2 == 0 or n2 == elementsCount[1] or n1 == elementsCount[0]: - # self.pd1[n3][n2][n1] = mirror.reverseMirrorVector(self.pd1[n3q][n2q][n1q]) - # self.pd3[n3][n2][n1] = mirror.mirrorVector(self.pd3[n3q][n2q][n1q]) - # else: - # self.pd1[n3][n2][n1] = mirror.mirrorVector(self.pd1[n3q][n2q][n1q]) - # self.pd3[n3][n2][n1] = mirror.reverseMirrorVector(self.pd3[n3q][n2q][n1q]) - # self.pd2[n3][n2][n1] = mirror.mirrorVector(self.pd2[n3q][n2q][n1q]) - self._elementsCount = elementsCount - - def generateBaseLeg(self, nodeparams): - """ - Generate base leg that is a cylinder generated from cylinder ends. - :return: - """ - bottomnodeparams = nodeparams[0] - topnodeparams = nodeparams[1] - self.genetateBottomSurface(bottomnodeparams) - self.generateTopSurface(topnodeparams) - self.generateMiddleLevels() - self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - # self.genetateBottomSurface([1.7, 0.0, 2.2], [1.7, 0.0, 1.2], [1.7, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.0, 0.0, -1 / self._elementsCount[1]]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateTopSurface([0.5, 0.0, 2.2], [1.2, 0.0, 1.0], [0.5, 1.0, 2.2], - # [[0.0, 0.0, -1 / self._elementsCount[1]], [0.5 * 0.7071, 0.0, -0.5 * 0.7071]], - # [[0.0, 1 / self._elementsCount[0], 0.0], [0.0, 1 / self._elementsCount[0], 0.0]]) - # self.generateMiddleLevels() - # self.smoothd2() - - # self.generateNodes(nodes, fieldmodule, coordinates) - # self.generateElements(mesh, fieldmodule, coordinates) - - def genetateBottomSurface(self, bottomnodeparams): - """ - Use major and minor curves to generate the ellipse - :return: - """ - xec1e, centre, xec1w, xec2, d1c1, d1c2 = bottomnodeparams[0], bottomnodeparams[1], bottomnodeparams[2], bottomnodeparams[3], bottomnodeparams[4], bottomnodeparams[5] - txc1, td1c1 = self.generate1DPath([xec1e, centre, xec1w], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]//2) - # txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - # txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, 0) - - def generateTopSurface(self, topnodeparams): - """ - - :return: - """ - xec1e, centre, xec1w, xec2, d1c1, d1c2 = topnodeparams[0], topnodeparams[1], topnodeparams[2], topnodeparams[3], topnodeparams[4], topnodeparams[5] - txc1, td1c1 = self.generate1DPath([xec1e, centre, xec1w], d1c1, self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]//2) - # txc1, td1c1 = self.generate1DPath([centre, xec1], d1c1, self._elementsCount[0]) - # txc2, td1c2 = self.generate1DPath([centre, xec2], d1c2, self._elementsCount[1]) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, self._elementsCount[2]) - - def generateMiddleLevels(self): - """ - - :return: - """ - btx = self.px - btd1 = self.pd1 - btd2 = self.pd2 - btd3 = self.pd3 - # generate the armpit curves. - elementsCountOut = self._elementsCount[2] - txcc1, td1cc1, pec, pxic, psfc = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][self._elementsCount[0]//2], - btx[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], - [btd2[0][self._elementsCount[1]//2][self._elementsCount[0]//2], - btd2[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], - elementsCountOut) - txec1w, td1ec1w, pec1w, pxic1w, psfc1w = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][0], btx[self._elementsCount[2]][self._elementsCount[1]//2][0]], - [btd2[0][self._elementsCount[1]//2][0], btd2[self._elementsCount[2]][self._elementsCount[1]//2][0]], - elementsCountOut) - txec1e, td1ec1e, pec1e, pxic1e, psfc1e = sampleCubicHermiteCurves([btx[0][self._elementsCount[1]//2][self._elementsCount[0]], btx[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], - [btd2[0][self._elementsCount[1]//2][self._elementsCount[0]], btd2[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], - elementsCountOut) - txec2, td1ec2, pec2, pxic2, psfc2 = sampleCubicHermiteCurves([btx[0][0][self._elementsCount[0]//2], btx[self._elementsCount[2]][0][self._elementsCount[0]//2]], - [btd2[0][0][self._elementsCount[0]//2], btd2[self._elementsCount[2]][0][self._elementsCount[0]//2]], - elementsCountOut) - - tdlcc1 = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][self._elementsCount[0]//2], - btd3[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlcc2 = interpolateSampleCubicHermite([btd1[0][self._elementsCount[1]//2][self._elementsCount[0]//2], - btd1[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]//2]], - [[0.0, 0.0, 0.0]] * 2, pec, pxic, psfc)[0] - tdlec1w = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][0], - btd3[self._elementsCount[2]][self._elementsCount[1]//2][0]], - [[0.0, 0.0, 0.0]] * 2, pec1w, pxic1w, psfc1w)[0] - tdlec1e = interpolateSampleCubicHermite([btd3[0][self._elementsCount[1]//2][self._elementsCount[0]], - btd3[self._elementsCount[2]][self._elementsCount[1]//2][self._elementsCount[0]]], - [[0.0, 0.0, 0.0]] * 2, pec1e, pxic1e, psfc1e)[0] - tdlec2 = interpolateSampleCubicHermite([btd3[0][0][self._elementsCount[0]//2], - btd3[self._elementsCount[2]][0][self._elementsCount[0]//2]], - [[0.0, 0.0, 0.0]] * 2, pec2, pxic2, psfc2)[0] - - for n3 in range(1, self._elementsCount[2]): - centre = txcc1[n3] - txc1, td1c1 = self.generate1DPath([txec1e[n3], centre, txec1w[n3]], [[-c for c in tdlec1e[n3]], [-c for c in tdlcc1[n3]], tdlec1w[n3]], self._elementsCount[0]) - txc2, td1c2 = self.generate1DPath([centre, txec2[n3]], [[-c for c in tdlcc2[n3]], tdlec2[n3]], self._elementsCount[1]//2) - ellipse = self.generateSurfaceUsingTwoCurves(centre, txc1, td1c1, txc2, td1c2) - self.copyEllipseNodesToBifurcation(ellipse, n3) - - def smoothd2(self): - """ - - :return: - """ - btx = self.px - btd1 = self.pd1 - btd2 = self.pd2 - btd3 = self.pd3 - # smooth d2 - for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 1): - if btx[0][n2][n1]: - nx = [] - nd1 = [] - for n3 in range(self._elementsCount[2] + 1): - nx.append(btx[n3][n2][n1]) - nd1.append(btd2[n3][n2][n1]) - td2 = smoothCubicHermiteDerivativesLine(nx, nd1) - for n3 in range(self._elementsCount[2] + 1): - btd2[n3][n2][n1] = td2[n3] - - def generate1DPath(self, nx, nd1, elementsCountOut): - """ - Given end nodes generate 1d path - :return: - """ - tx, td1, pe, pxi, psf = sampleCubicHermiteCurves(nx, nd1, elementsCountOut, arcLengthDerivatives = True) - return tx, td1 - - def generateSurfaceUsingTwoCurves(self, centre, txc1, td1c1, txc2, td1c2): - """ - Get major and minor curves to generate the rounded surface. - :return: - """ - - # self._coreMinorRadii.append( - # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMinor) * self._minorRadii[n3]) - # self._coreMajorRadii.append( - # (1 - self._shellProportion * self._elementsCountAcrossShell / elementsMajor) * self._majorRadii[n3]) - - # ratio = rx/self.elementsCountAcrossShell if self.elementsCountAcrossShell > 0 else 0 - # majorAxis = [d*(1 - ratio*(1-self.coreMajorRadius/self.majorRadius)) for d in self.majorAxis] - # minorAxis = [d*(1 - ratio*(1-self.coreMinorRadius/self.minorRadius)) for d in self.minorAxis] - majorAxis = [c*(self._elementsCount[0]//2) for c in td1c2[0]] - minorAxis = [-c*(self._elementsCount[1]//2) for c in td1c1[self._elementsCount[1]//2]] - elementsCountAcrossShell = 0 - elementsCountAcrossTransition = 1 - shellProportion = 1.0 - coreMajorRadius = 1.0 - coreMinorRadius = 1.0 - # elementsCountAround = self._elementsCount[0] + self._elementsCount[1] - 2 - elementsCountAround = 2*(self._elementsCount[0]//2 + self._elementsCount[1]//2 - 2) - # ellipse = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], - # elementsCountAcrossShell, elementsCountAcrossTransition, - # shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - ellipse = Ellipse2D(centre, majorAxis, minorAxis, self._elementsCount[0], self._elementsCount[1], - elementsCountAcrossShell, elementsCountAcrossTransition, - shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) - - shield = ellipse.getShield() - ellipse.generateBase1DMesh(0) - - # Modify nodes around the ellipse. - ellipse.px[self._elementsCount[1]//2][0] = txc1[-1] - ellipse.pd3[self._elementsCount[1]//2][0] = td1c1[-1] - ellipse.px[self._elementsCount[1]//2][self._elementsCount[0]] = txc1[0] - ellipse.pd3[self._elementsCount[1]//2][self._elementsCount[0]] = vector.scaleVector(td1c1[0], -1) - ellipse.px[0][self._elementsCount[0]//2] = txc2[-1] - ellipse.pd3[0][self._elementsCount[0]//2] = td1c2[-1] - - normal = vector.normalise(vector.crossproduct3(td1c1[self._elementsCount[1]//2], td1c2[0])) - - nx = [] - nd1 = [] - for n in range(elementsCountAround + 1): - n1, n2 = shield.convertRimIndex(n) - if n <= elementsCountAround // 2: - nq = n - point1 = txc1[-1] - point2 = txc2[-1] - else: - nq = n - elementsCountAround//2 - point1 = txc2[-1] - point2 = txc1[0] - delta_p_normal = self.point_displacement(nq, centre, point1, point2, elementsCountAround//2, normal) - if 0 < nq < elementsCountAround//2: - ellipse.px[n2][n1] = vector.addVectors([ellipse.px[n2][n1], delta_p_normal], [1, 1]) - nx.append(ellipse.px[n2][n1]) - nd1.append(ellipse.pd1[n2][n1]) - td1 = smoothCubicHermiteDerivativesLine(nx, nd1) - for n in range(1, elementsCountAround): - n1, n2 = shield.convertRimIndex(n) - ellipse.pd1[n2][n1] = td1[n] - - # Create internal nodes and mirror to get the other half. - ellipse.setRimNodes() - rscx, rscd1, rscd2, rscd3 = ellipse.createMirrorCurve() - ellipse.createRegularRowCurves(ellipse.px[:self._elementsCount[1]//2+1][self._elementsCount[0]//2], rscd1, rscd3) - ellipse.createRegularColumnCurves() - shield.getTriplePoints(0) - ellipse.smoothTriplePointsCurves() - ellipse.smoothTransitionRims() - if ellipse.ellipseShape == EllipseShape.Ellipse_SHAPE_FULL: - ellipse.generateNodesForUpperHalf() - - # smooth triple1 - nx = [ellipse.px[1][1], ellipse.px[0][1]] - nd1 = [[-ellipse.pd1[1][1][c]-ellipse.pd3[1][1][c] for c in range(3)], ellipse.pd3[0][1]] - td3 = smoothCubicHermiteDerivativesLine(nx, nd1) - - ellipse.pd3[0][1] = td3[1] - - # Calculate d2. - for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 1): - if ellipse.px[n2][n1]: - ellipse.pd2[n2][n1] = vector.crossproduct3(ellipse.pd3[n2][n1], ellipse.pd1[n2][n1]) - - return ellipse - - def copyEllipseNodesToBifurcation(self, ellipse, n3): - """ - Copy ellipse nodes to bifurcation - :param ellipse: - :return: - """ - - for n2 in range(self._elementsCount[1] + 1): - for n1 in range(self._elementsCount[0] + 1): - n2e, n1e = n2, n1 - self.px[n3][n2][n1] = ellipse.px[n2e][n1e] - self.pd1[n3][n2][n1] = ellipse.pd1[n2e][n1e] - self.pd2[n3][n2][n1] = ellipse.pd2[n2e][n1e] - self.pd3[n3][n2][n1] = ellipse.pd3[n2e][n1e] - - # def warp_ellipse(self, centre, point1, point2, elementsCountAround, shield, ellipse): - # """ - # - # :return: - # """ - # - # - # ellipse.px[self._elementsCount[1] // 2][0] = txc1[-1] # point1 - # ellipse.pd3[self._elementsCount[1] // 2][0] = td1c1[-1] # point1d3 - # ellipse.px[0][self._elementsCount[0] // 2] = txc2[-1] # point2 - # ellipse.pd3[0][self._elementsCount[0] // 2] = td1c2[-1] # point2d3 - # - # # centre = ellipse.px[self._elementsCount[1] // 2][self._elementsCount[0] // 2] - # # point1 = ellipse.px[self._elementsCount[1] // 2][0] - # # point2 = ellipse.px[0][self._elementsCount[0] // 2] - # normal = vector.normalise(vector.crossproduct3(td1c1[0], td1c2[0])) - # delta = [point1[c] - point2[c] for c in range(3)] - # - # nx = [] - # nd1 = [] - # for n in range(elementsCountAround + 1): - # delta_p_normal = self.point_displacement(n, centre, point1, point2, elementsCountAround, normal) - # - # # Modify points around the ellipse. Warp it. - # n1, n2 = shield.convertRimIndex(n) - # if 0 < n < elementsCountAround: - # ellipse.px[n2][n1] = vector.addVectors([ellipse.px[n2][n1], delta_p_normal], [1, 1]) - # nx.append(ellipse.px[n2][n1]) - # nd1.append(ellipse.pd1[n2][n1]) - # td1 = smoothCubicHermiteDerivativesLine(nx, nd1) - - def point_displacement(self, n, centre, point1, point2, elementsCountAround, normal): - """ - :param normal: unit normal vector of an ellipse in centre. - :return: displacement vector for a node on the ellipse between point1 and point2. - """ - xi = n / elementsCountAround - x_p = vector.addVectors([vector.scaleVector(point1, 1 - xi), vector.scaleVector(point2, xi)], [1, 1]) - - delta_p = vector.addVectors([x_p, centre], [1, -1]) - delta_p_normalmag = vector.dotproduct(delta_p, normal) - delta_p_normal = vector.scaleVector(normal, delta_p_normalmag) - - return delta_p_normal \ No newline at end of file From abeda325d1b49cc8a2ac9975ef1c986d3453484a Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 5 Sep 2022 08:47:52 +1200 Subject: [PATCH 35/38] conflicts 1 --- .../meshtypes/meshtype_3d_wholebody1.py | 4 --- .../meshtypes/meshtype_3d_wholebody2.py | 32 ------------------- src/scaffoldmaker/scaffolds.py | 24 -------------- 3 files changed, 60 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py index e32f7400..a837f012 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py @@ -406,11 +406,7 @@ def generateBaseMesh(region, options): 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('esophagogastric junction along the lesser curvature on serosa') -<<<<<<< HEAD limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge at the greater curvature on serosa') -======= - limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge along the greater curvature on serosa') ->>>>>>> cd0dea4 (Update annotation terms for the stomach) 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') diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py index a6e9a80b..b98b669e 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py @@ -63,37 +63,6 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Left arm radius': 0.6, 'Lower torso length': 2.6, 'Lower torso number of elements': 4, -<<<<<<< HEAD - 'Lower torso radii': [1.3, 1.0], - 'Neck height': 3.6, -<<<<<<< HEAD - 'Right arm angle': 0.0, -<<<<<<< HEAD - 'Right arm length': 1.7, -======= - 'Left arm angle': 0.0, - 'Right shoulder length': 0.95, -======= - 'Neck length': 0.4, - 'Neck number of elements': 2, - 'Neck radius': 0.8, - 'Neck radius 2': 0.8, ->>>>>>> 5bc5787 (change the order of options) - 'Right arm length': 2.0, - 'Right arm number of elements': 5, - 'Right arm radius': 1.0, - 'Right shoulder length': 0.95, - 'Right wrist radius': 0.8, -<<<<<<< HEAD - 'Lower torso length': 5.5, - 'Lower torso number of elements': 4, - 'Lower torso radii': [1.3, 1.0], ->>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) -======= - 'Shoulder height': 2.2, - 'Torso radius': 1.0, ->>>>>>> 5bc5787 (change the order of options) -======= 'Lower torso radii': [1.3, 1.6], 'Neck height': 3.3, 'Neck length': 0.2, @@ -107,7 +76,6 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Right wrist radius': 0.4, 'Shoulder height': 2.1, 'Torso radius': 1.3, ->>>>>>> 3e2b739 (Minor changes) 'Number of elements across major': 4, 'Number of elements across shell': 0, 'Number of elements across transition': 1, diff --git a/src/scaffoldmaker/scaffolds.py b/src/scaffoldmaker/scaffolds.py index 892e7620..ee6184f7 100644 --- a/src/scaffoldmaker/scaffolds.py +++ b/src/scaffoldmaker/scaffolds.py @@ -38,23 +38,11 @@ from scaffoldmaker.meshtypes.meshtype_3d_musclefusiform1 import MeshType_3d_musclefusiform1 from scaffoldmaker.meshtypes.meshtype_3d_ostium1 import MeshType_3d_ostium1 from scaffoldmaker.meshtypes.meshtype_3d_smallintestine1 import MeshType_3d_smallintestine1 -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -======= -from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation1 import MeshType_3d_solidbifurcation1 -from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation2 import MeshType_3d_solidbifurcation2 ->>>>>>> cfec53f (copied to 2nd one) -======= ->>>>>>> 85d7286 (rename filenames) from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere2 import MeshType_3d_solidsphere2 -======= -from scaffoldmaker.meshtypes.meshtype_3d_solidbifurcation1 import MeshType_3d_solidbifurcation1 from scaffoldmaker.meshtypes.meshtype_3d_solidcylinder1 import MeshType_3d_solidcylinder1 from scaffoldmaker.meshtypes.meshtype_3d_solidsphere1 import MeshType_3d_solidsphere1 ->>>>>>> ef3433d (initial code) from scaffoldmaker.meshtypes.meshtype_3d_sphereshell1 import MeshType_3d_sphereshell1 from scaffoldmaker.meshtypes.meshtype_3d_sphereshellseptum1 import MeshType_3d_sphereshellseptum1 from scaffoldmaker.meshtypes.meshtype_3d_stellate1 import MeshType_3d_stellate1 @@ -106,23 +94,11 @@ def __init__(self): MeshType_3d_musclefusiform1, MeshType_3d_ostium1, MeshType_3d_smallintestine1, -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD -======= - MeshType_3d_solidbifurcation1, - MeshType_3d_solidbifurcation2, ->>>>>>> cfec53f (copied to 2nd one) -======= ->>>>>>> 85d7286 (rename filenames) MeshType_3d_solidcylinder1, MeshType_3d_solidsphere1, MeshType_3d_solidsphere2, -======= - MeshType_3d_solidbifurcation1, MeshType_3d_solidcylinder1, MeshType_3d_solidsphere1, ->>>>>>> ef3433d (initial code) MeshType_3d_sphereshell1, MeshType_3d_sphereshellseptum1, MeshType_3d_stellate1, From ebd7da7c69df968c227e49d1248b4b9fa3d13bb8 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 6 Sep 2022 13:14:20 +1200 Subject: [PATCH 36/38] Fix conflicts 1 --- src/scaffoldmaker/utils/cylindermesh.py | 18 ++++-------------- src/scaffoldmaker/utils/shieldmesh.py | 13 ++++--------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index db2e9f3c..4f2a3c6a 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -136,11 +136,9 @@ class CylinderMesh: def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end=None, cylinderShape=CylinderShape.CYLINDER_SHAPE_FULL, -<<<<<<< HEAD - tapered=None, cylinderCentralPath=None, useCrossDerivatives=False , meshGroupsElementsAlong=[], meshGroups=[]): -======= - tapered=None, cylinderCentralPath=None, useCrossDerivatives=False, rangeOfRequiredElementsAlong=None): ->>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) + tapered=None, cylinderCentralPath=None, useCrossDerivatives=False, meshGroupsElementsAlong=[], + meshGroups=[], rangeOfRequiredElementsAlong=None): + """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -398,13 +396,8 @@ def generateElements(self, mesh, fieldModule, coordinates, rangeOfRequiredElemen """ elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier -<<<<<<< HEAD - elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, - self._meshGroupsElementsAlong, self._meshGroups) -======= - elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, [], + elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, [], [], rangeOfRequiredElementsAlong=rangeOfRequiredElementsAlong) ->>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) self._endElementIdentifier = elementIdentifier def getElementsCountAround(self): @@ -768,7 +761,6 @@ def generateNodesForUpperHalf(self): self.pd3[2 * self.elementsCountUp - n2][n1] = mirror.mirrorVector( self.pd3[n2][n1]) -<<<<<<< HEAD def calculateD2(self): """ :return: @@ -782,8 +774,6 @@ def calculateD2(self): if btx[n2][n1]: btd2[n2][n1] = nte -======= ->>>>>>> 33b365c (half of the right armpit) def getShield(self): return self.__shield diff --git a/src/scaffoldmaker/utils/shieldmesh.py b/src/scaffoldmaker/utils/shieldmesh.py index f5e06bc7..ea57544b 100644 --- a/src/scaffoldmaker/utils/shieldmesh.py +++ b/src/scaffoldmaker/utils/shieldmesh.py @@ -483,12 +483,9 @@ def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPla return nodeIdentifier -<<<<<<< HEAD - def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroupsElementsAlong=[], meshGroups=[]): -======= - def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroups=[], - rangeOfRequiredElementsAlong=None): ->>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) + + def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroupsElementsAlong=[], + meshGroups=[], rangeOfRequiredElementsAlong=None): """ Create shield elements from nodes. :param fieldmodule: Zinc fieldmodule to create elements in. @@ -513,16 +510,14 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes elementtemplate1 = mesh.createElementtemplate() elementtemplate1.setElementShapeType(Element.SHAPE_TYPE_CUBE) -<<<<<<< HEAD elementEnd = [] count = 0 for c in meshGroupsElementsAlong: count += c elementEnd.append(count) -======= + if rangeOfRequiredElementsAlong is None: rangeOfRequiredElementsAlong = [0, self.elementsCountAlong] ->>>>>>> e91ccef (Add range of elements along cylinder parameter. Add arms,neck and head.) isEven = (self.elementsCountAcross % 2) == 0 e1a = self.elementsCountRim From 648ac78f7a9aa4eb242c1d837c900f89c9e2fabd Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Fri, 9 Sep 2022 10:53:43 +1200 Subject: [PATCH 37/38] Make the stickman same scale as the body scaffold. Get angles from the modified nodes. --- .../meshtypes/meshtype_1d_stickman1.py | 47 +++++++++++++++++-- .../meshtypes/meshtype_3d_wholebody2.py | 44 +++++++++++------ 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py index b2fc6f98..d4d3a3a3 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_1d_stickman1.py @@ -25,13 +25,25 @@ def getName(): @staticmethod def getDefaultOptions(parameterSetName='Default'): return { - 'Coordinate dimensions' : 3, + 'Coordinate dimensions': 3, + 'Arm length': 1.0, + 'Leg length': 1.0, + 'Left arm angle': 0.0, + 'Left leg angle': 1.2, + 'Right arm angle': 0.0, + 'Right leg angle': 1.2, } @staticmethod def getOrderedOptionNames(): return [ - 'Coordinate dimensions' + 'Coordinate dimensions', + 'Arm length', + 'Leg length', + 'Left arm angle', + 'Left leg angle', + 'Right arm angle', + 'Right leg angle', ] @staticmethod @@ -52,6 +64,13 @@ def generateBaseMesh(cls, region, options): coordinates = findOrCreateFieldCoordinates(fieldmodule, components_count=3) cache = fieldmodule.createFieldcache() + arm_length = options['Arm length'] + leg_length = options['Leg length'] + left_arm_angle = options['Left arm angle'] + left_leg_angle = options['Left leg angle'] + Right_arm_angle = options['Right arm angle'] + Right_leg_angle = options['Right leg angle'] + six_stick = True ################# # Create nodes @@ -64,14 +83,34 @@ def generateBaseMesh(cls, region, options): nodetemplate.setValueNumberOfVersions(coordinates, -1, Node.VALUE_LABEL_D_DS1, 1) nodeIdentifier = 1 + height = arm_length + arm_length + leg_length + longitudinal = [0.0, 0.0, 1.0] + transverse = [1.0, 0.0, 0.0] + sagittal = vector.crossproduct3(longitudinal, transverse) + x_head = vector.scaleVector(longitudinal, height) + x_shoulder = vector.scaleVector(longitudinal, 0.75*height) + x_hip = vector.scaleVector(longitudinal, 0.5*height) + x_centre = vector.scaleVector(vector.addVectors([x_shoulder, x_hip], [1, 1]), 0.5) + x_left_hand = vector.scaleVector(vector.rotateVectorAroundVector(transverse, + sagittal, left_arm_angle), arm_length) + x_left_hand = vector.addVectors([x_shoulder, x_left_hand], [1, 1]) + x_right_hand = vector.scaleVector(vector.rotateVectorAroundVector(vector.scaleVector(transverse, -1), + sagittal, -Right_arm_angle), arm_length) + x_right_hand = vector.addVectors([x_shoulder, x_right_hand], [1, 1]) + x_left_leg = vector.scaleVector(vector.rotateVectorAroundVector(transverse, sagittal, + left_leg_angle), leg_length) + x_left_leg = vector.addVectors([x_hip, x_left_leg], [1, 1]) + x_right_leg = vector.scaleVector(vector.rotateVectorAroundVector(vector.scaleVector(transverse, -1), + sagittal, -Right_leg_angle), leg_length) + x_right_leg = vector.addVectors([x_hip, x_right_leg], [1, 1]) if six_stick: - x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], - [-0.25, 0.0, 0.81], [-0.01, 0.0, 0.0], [0.25, 0.0, 0.81], [0.01, 0.0, 0.0]] + x_list = [x_head, x_shoulder, x_hip, x_right_hand, x_right_leg, x_left_hand, x_left_leg] else: x_list = [[0.0, 0.0, 1.0], [0.0, 0.0, 0.75], [0.0, 0.0, 0.5], [-0.25, 0.0, 0.81], [-0.25, 0.0, 0.25], [0.25, 0.0, 0.81], [0.25, 0.0, 0.25], [-0.5, 0.0, 0.87] , [-0.5, 0.0, 0.0], [0.5, 0.0, 0.87], [0.5, 0.0, 0.0]] + x_list = [vector.addVectors([x, x_centre], [1, -1]) for x in x_list] for x in x_list: node = nodes.createNode(nodeIdentifier, nodetemplate) cache.setNode(node) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py index b98b669e..054da3f4 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py @@ -43,6 +43,12 @@ class MeshType_3d_wholebody2(Scaffold_base): 'control curves': ScaffoldPackage(MeshType_1d_stickman1, { 'scaffoldSettings': { 'Coordinate dimensions': 3, + 'Arm length': 3.5, + 'Leg length': 6.0, + 'Left arm angle': 0.0, + 'Left leg angle': 1.56, + 'Right arm angle': 0.0, + 'Right leg angle': 1.56 } }), } @@ -118,7 +124,7 @@ def getOrderedOptionNames(): @classmethod def getOptionValidScaffoldTypes(cls, optionName): if optionName == 'Central path': - return [MeshType_1d_path1] + return [MeshType_1d_stickman1] return [] @classmethod @@ -186,31 +192,33 @@ def generateBaseMesh(region, options): shellProportion = options['Shell element thickness proportion'] useCrossDerivatives = options['Use cross derivatives'] - torso_radius = options['Torso radius'] - left_arm_radius = options['Left arm radius'] - right_arm_radius = options['Right arm radius'] - neck_radius = options['Neck radius'] - neck_radius2 = options['Neck radius 2'] - neck_length = options['Neck length'] - neck_number_of_elements = options['Neck number of elements'] - shoulder_height = options['Shoulder height'] - neck_height = options['Neck height'] - right_shoulder_length = options['Right shoulder length'] - right_arm_length = options['Right arm length'] - rightArmNumberOfElements = options['Right arm number of elements'] - righ_wrist_radius = options['Right wrist radius'] armpit = options['Armpit'] head_length = options['Head length'] head_number_of_elements = options['Head number of elements'] head_radius = options['Head radius'] + left_arm_radius = options['Left arm radius'] lower_torso_length = options['Lower torso length'] lower_torso_number_of_elements = options['Lower torso number of elements'] lower_torso_radii = options['Lower torso radii'] + neck_height = options['Neck height'] + neck_length = options['Neck length'] + neck_number_of_elements = options['Neck number of elements'] + neck_radius = options['Neck radius'] + neck_radius2 = options['Neck radius 2'] + righ_wrist_radius = options['Right wrist radius'] + rightArmNumberOfElements = options['Right arm number of elements'] + right_arm_length = options['Right arm length'] + right_arm_radius = options['Right arm radius'] + right_shoulder_length = options['Right shoulder length'] + shoulder_height = options['Shoulder height'] + torso_radius = options['Torso radius'] fm = region.getFieldmodule() coordinates = findOrCreateFieldCoordinates(fm) tmpRegion = region.createRegion() + scaffoldSettings = centralPath.getScaffoldSettings() + scaffoldSettings['Arm length'] = right_arm_length centralPath.generate(tmpRegion) cx = extractPathParametersFromRegion(tmpRegion, [Node.VALUE_LABEL_VALUE])[0] @@ -227,6 +235,14 @@ def limb_angle(p1, p2): right_leg_angle = limb_angle(cx[2], cx[4]) left_leg_angle = limb_angle(cx[2], cx[6]) + if centralPath._meshEdits: + scaffoldSettings['Left arm angle'] = left_arm_angle + scaffoldSettings['Left leg angle'] = left_leg_angle + scaffoldSettings['Right arm angle'] = right_arm_angle + scaffoldSettings['Right leg angle'] = right_leg_angle + centralPath._meshEdits = None + centralPath.generate(tmpRegion) + # create torso, head and arms trifurcation1 = TrifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, neck_radius, shoulder_height, neck_height, right_arm_angle, left_arm_angle, From 225f49a6e4c5b8019efe9615b5d33672915b90a6 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Mon, 19 Sep 2022 13:51:09 +1200 Subject: [PATCH 38/38] Add left leg centralpath --- .../meshtypes/meshtype_3d_wholebody2.py | 118 +++++++++++++----- src/scaffoldmaker/utils/bifurcation3d.py | 56 +++++---- 2 files changed, 120 insertions(+), 54 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py index 054da3f4..80e23a49 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody2.py @@ -23,24 +23,7 @@ class MeshType_3d_wholebody2(Scaffold_base): with features to control arms, torso, neck and head. """ centralPathDefaultScaffoldPackages = { - # 'Cylinder 1': ScaffoldPackage(MeshType_1d_path1, { - # 'scaffoldSettings': { - # 'Coordinate dimensions': 3, - # 'D2 derivatives': True, - # 'D3 derivatives': True, - # 'Length': 3.0, - # 'Number of elements': 3 - # }#, - # # 'meshEdits': exnodeStringFromNodeValues( - # # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, - # # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ - # # [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - # # [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - # # [[0.0, 0.0, 2.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], - # # [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] - # # ]) - # }), - 'control curves': ScaffoldPackage(MeshType_1d_stickman1, { + 'Stickman': ScaffoldPackage(MeshType_1d_stickman1, { 'scaffoldSettings': { 'Coordinate dimensions': 3, 'Arm length': 3.5, @@ -51,6 +34,46 @@ class MeshType_3d_wholebody2(Scaffold_base): 'Right leg angle': 1.56 } }), + 'Left arm': ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Number of elements': 3 + } # , + # 'meshEdits': exnodeStringFromNodeValues( + # [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + # Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], [ + # [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # [[0.0, 0.0, 2.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]], + # [[0.0, 0.0, 3.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]] + # ]) + }), + 'Left leg': ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Number of elements': 3 + } + }), + 'Right arm': ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Number of elements': 3 + } + }), + 'Right leg': ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Number of elements': 3 + } + }), } @staticmethod @@ -59,9 +82,17 @@ def getName(): @classmethod def getDefaultOptions(cls, parameterSetName='Default'): - centralPathOption = cls.centralPathDefaultScaffoldPackages['control curves'] + stickmanOption = cls.centralPathDefaultScaffoldPackages['Stickman'] + leftArmOption = cls.centralPathDefaultScaffoldPackages['Left arm'] + leftLegOption = cls.centralPathDefaultScaffoldPackages['Left leg'] + rightArmOption = cls.centralPathDefaultScaffoldPackages['Right arm'] + rightLegOption = cls.centralPathDefaultScaffoldPackages['Right leg'] options = { - 'Central path': copy.deepcopy(centralPathOption), + 'Stickman': copy.deepcopy(stickmanOption), + 'Left arm central path': copy.deepcopy(leftArmOption), + 'Left leg central path': copy.deepcopy(leftLegOption), + 'Right arm central path': copy.deepcopy(rightArmOption), + 'Right leg central path': copy.deepcopy(rightLegOption), 'Armpit': [1.6, 0.0, 1.2], 'Head length': 1.5, 'Head number of elements': 5, @@ -96,7 +127,11 @@ def getDefaultOptions(cls, parameterSetName='Default'): @staticmethod def getOrderedOptionNames(): return [ - 'Central path', + 'Stickman', + 'Left arm central path', + 'Left leg central path', + 'Right arm central path', + 'Right leg central path', 'Armpit', 'Head length', 'Head number of elements', @@ -123,13 +158,19 @@ def getOrderedOptionNames(): @classmethod def getOptionValidScaffoldTypes(cls, optionName): - if optionName == 'Central path': + if optionName == 'Stickman': return [MeshType_1d_stickman1] + elif optionName in ['Left arm central path', 'Left leg central path', + 'Right arm central path', 'Right leg central path']: + return [MeshType_1d_path1] return [] @classmethod def getOptionScaffoldTypeParameterSetNames(cls, optionName, scaffoldType): - if optionName == 'Central path': + if optionName == 'Stickman': + return list(cls.centralPathDefaultScaffoldPackages.keys()) + elif optionName in ['Left arm central path', 'Left leg central path', + 'Right arm central path', 'Right leg central path']: return list(cls.centralPathDefaultScaffoldPackages.keys()) assert scaffoldType in cls.getOptionValidScaffoldTypes(optionName), \ cls.__name__ + '.getOptionScaffoldTypeParameterSetNames. ' + \ @@ -146,7 +187,12 @@ def getOptionScaffoldPackage(cls, optionName, scaffoldType, parameterSetName=Non assert parameterSetName in cls.getOptionScaffoldTypeParameterSetNames(optionName, scaffoldType), \ 'Invalid parameter set ' + str(parameterSetName) + ' for scaffold ' + str(scaffoldType.getName()) + \ ' in option ' + str(optionName) + ' of scaffold ' + cls.getName() - if optionName == 'Central path': + if optionName == 'Stickman': + if not parameterSetName: + parameterSetName = list(cls.centralPathDefaultScaffoldPackages.keys())[0] + return copy.deepcopy(cls.centralPathDefaultScaffoldPackages[parameterSetName]) + elif optionName in ['Left arm central path', 'Left leg central path', + 'Right arm central path', 'Right leg central path']: if not parameterSetName: parameterSetName = list(cls.centralPathDefaultScaffoldPackages.keys())[0] return copy.deepcopy(cls.centralPathDefaultScaffoldPackages[parameterSetName]) @@ -154,8 +200,8 @@ def getOptionScaffoldPackage(cls, optionName, scaffoldType, parameterSetName=Non @classmethod def checkOptions(cls, options): - if not options['Central path'].getScaffoldType() in cls.getOptionValidScaffoldTypes('Central path'): - options['Central path'] = cls.getOptionScaffoldPackage('Central path', MeshType_1d_path1) + if not options['Stickman'].getScaffoldType() in cls.getOptionValidScaffoldTypes('Stickman'): + options['Stickman'] = cls.getOptionScaffoldPackage('Stickman', MeshType_1d_stickman1) dependentChanges = False if options['Number of elements across major'] < 4: @@ -185,7 +231,11 @@ def generateBaseMesh(region, options): :return: None """ - centralPath = options['Central path'] + stickman = options['Stickman'] + left_arm_central_path = options['Left arm central path'] + left_leg_central_path = options['Left leg central path'] + right_arm_central_path = options['Right arm central path'] + right_leg_central_path = options['Right leg central path'] elementsCountAcrossMajor = options['Number of elements across major'] elementsCountAcrossShell = options['Number of elements across shell'] elementsCountAcrossTransition = options['Number of elements across transition'] @@ -217,9 +267,9 @@ def generateBaseMesh(region, options): coordinates = findOrCreateFieldCoordinates(fm) tmpRegion = region.createRegion() - scaffoldSettings = centralPath.getScaffoldSettings() + scaffoldSettings = stickman.getScaffoldSettings() scaffoldSettings['Arm length'] = right_arm_length - centralPath.generate(tmpRegion) + stickman.generate(tmpRegion) cx = extractPathParametersFromRegion(tmpRegion, [Node.VALUE_LABEL_VALUE])[0] def limb_angle(p1, p2): @@ -235,13 +285,14 @@ def limb_angle(p1, p2): right_leg_angle = limb_angle(cx[2], cx[4]) left_leg_angle = limb_angle(cx[2], cx[6]) - if centralPath._meshEdits: + # set the angles and regenerate the stickman with the new settings. + if stickman.getMeshEdits(): scaffoldSettings['Left arm angle'] = left_arm_angle scaffoldSettings['Left leg angle'] = left_leg_angle scaffoldSettings['Right arm angle'] = right_arm_angle scaffoldSettings['Right leg angle'] = right_leg_angle - centralPath._meshEdits = None - centralPath.generate(tmpRegion) + stickman.setMeshEdits(None) + stickman.generate(tmpRegion) # create torso, head and arms trifurcation1 = TrifurcationMesh(fm, coordinates, region, torso_radius, left_arm_radius, right_arm_radius, @@ -298,7 +349,8 @@ def limb_angle(p1, p2): # create the legs bifurcation1 = BifurcationMesh(fm, coordinates, region, [0, 0, -lower_torso_length], lower_torso_radii, - right_leg_angle, left_leg_angle, part1=lower_torso_cylinder) + right_leg_angle, left_leg_angle, + left_leg_central_path, right_leg_central_path, part1=lower_torso_cylinder) # trifurcation1.smooth_all_derivatives() diff --git a/src/scaffoldmaker/utils/bifurcation3d.py b/src/scaffoldmaker/utils/bifurcation3d.py index 81e881cf..7b382898 100644 --- a/src/scaffoldmaker/utils/bifurcation3d.py +++ b/src/scaffoldmaker/utils/bifurcation3d.py @@ -70,8 +70,8 @@ class BranchCylinder: """ Generates a cylinder on top of the given part. """ - def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, elements_count, part1, - attach_bottom=True): + def __init__(self, region, mesh, nodes, fieldmodule, coordinates, elements_count, part1, + attach_bottom=True, path_list=None, centralPath=None, centre=None): """ Generate a cylinder to extend part1. see PathNodes class. :param region: Zinc region @@ -93,22 +93,32 @@ def __init__(self, region, mesh, nodes, fieldmodule, coordinates, path_list, ele node_ranges = [0, elements_count[2] - 1] # generate the cylinder - centralPath = ScaffoldPackage(MeshType_1d_path1, { - 'scaffoldSettings': { - 'Coordinate dimensions': 3, - 'D2 derivatives': True, - 'D3 derivatives': True, - 'Length': 1.0, - 'Number of elements': len(path_list) - 1 - }, - 'meshEdits': exnodeStringFromNodeValues( - [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, - Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], + if not centralPath: + centralPath = ScaffoldPackage(MeshType_1d_path1, { + 'scaffoldSettings': { + 'Coordinate dimensions': 3, + 'D2 derivatives': True, + 'D3 derivatives': True, + 'Length': 1.0, + 'Number of elements': len(path_list) - 1 + }, + 'meshEdits': exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, + Node.VALUE_LABEL_D2_DS1DS2, Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], + path_list) + }) + centre = path_list[0][0] + if not centralPath._meshEdits: + centralPath_settings = centralPath.getScaffoldSettings() + centralPath_settings['Number of elements'] = len(path_list) - 1 + centralpath_meshEdits = exnodeStringFromNodeValues( + [Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2, + Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3], path_list) - }) + centralPath.setMeshEdits(centralpath_meshEdits) cylinderCentralPath = CylinderCentralPath(region, centralPath, elements_count[2]) cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL - centre = path_list[0][0] + base = CylinderEnds(elements_count[1], elements_count[0], 0, 1, 1.0, centre, cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], cylinderCentralPath.minorRadii[0]) @@ -352,7 +362,7 @@ def create_branch_cylinder(self, radius, length, number_of_elements, path_list=N pn = PathNodes(part1, radius, length, number_of_elements, attach_bottom=attach_bottom) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, - path_list, number_of_elements, part1, attach_bottom=attach_bottom) + number_of_elements, part1, attach_bottom=attach_bottom, path_list=path_list) cylinder = bc.get_cylinder() return cylinder @@ -2391,7 +2401,8 @@ class BifurcationMesh: Bifurction mesh generator. """ - def __init__(self, fieldModule, coordinates, region, centre, radii, right_leg_angle, left_leg_angle, part1=None): + def __init__(self, fieldModule, coordinates, region, centre, radii, right_leg_angle, left_leg_angle, + left_leg_central_path, right_leg_central_path, part1=None): """ :param fieldModule: Zinc fieldModule to create elements in. :param coordinates: Coordinate field to define. @@ -2404,6 +2415,8 @@ def __init__(self, fieldModule, coordinates, region, centre, radii, right_leg_an self._radii = radii self.right_leg_angle = right_leg_angle self.left_leg_angle = left_leg_angle + self._left_leg_central_path = left_leg_central_path + self._right_leg_central_path = right_leg_central_path self._part1 = part1 self._coordinates = coordinates @@ -2482,12 +2495,12 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): hip_distance)], [1, 1]) Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) # Lv = vector.setMagnitude(vector.rotateVectorAroundVector(xa, kv, angle), hip_length) - centre = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) + centre_l = vector.addVectors([x_hip_joint, [0, 0, 0]], [1, 1]) # centre = vector.addVectors([centre1, Lv], [1, 1]) minorAxis = vector.setMagnitude(vector.vectorRejection(vector.scaleVector(xa, -1), Lv), radius1) majorAxis = vector.setMagnitude(vector.crossproduct3(Lv, minorAxis), radius2) - ellipse3 = Ellipse2D(centre, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], + ellipse3 = Ellipse2D(centre_l, majorAxis, minorAxis, 2*self._elementsCount[0], 2*self._elementsCount[1], elementsCountAcrossShell, elementsCountAcrossTransition, shellProportion, coreMajorRadius, coreMinorRadius, ellipseShape=EllipseShape.Ellipse_SHAPE_FULL) @@ -2573,14 +2586,15 @@ def createBifurcationMesh3d(self, fieldmodule, coordinates): pn = PathNodes(hip_left, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() + bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, - path_list, [4, 4, 7], hip_left, attach_bottom=False) + [4, 4, 7], hip_left, attach_bottom=False, path_list=path_list, centralPath=self._left_leg_central_path, centre=centre_l) cylinder = bc.get_cylinder() pn = PathNodes(hip_right, [[radius1]*2, [radius1*0.8]*2], 6.0, [4, 4, 7], attach_bottom=False) path_list = pn.get_path_list() bc = BranchCylinder(self._region, self._mesh, self._nodes, self._fieldmodule, self._coordinates, - path_list, [4, 4, 7], hip_right, attach_bottom=False) + [4, 4, 7], hip_right, attach_bottom=False, path_list=path_list) cylinder = bc.get_cylinder() def generateNodes(self, nodes, fieldModule, coordinates, part_structure):