Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lungs #101

Merged
merged 23 commits into from
Nov 20, 2020
Merged

Lungs #101

merged 23 commits into from
Nov 20, 2020

Conversation

zekh167
Copy link
Contributor

@zekh167 zekh167 commented Nov 17, 2020

No description provided.

Copy link
Member

@rchristie rchristie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove lungs1 scaffold and keep only lung1.
If you copied lungs1 to lung1 with the operating system and not using 'git mv oldname newname' then it will have lost its history. Let me know if you want help getting it back.

from opencmiss.zinc.node import Node


class MeshType_3d_lungs1(Scaffold_base):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file. You committed both lungs1 and lung1.
In future use:
git mv old_file_name new_file_name
to tell git to rename it.

Comment on lines 43 to 52
@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()
assert False, cls.__name__ + '.getOptionScaffoldPackage: Option ' + optionName + ' is not a scaffold'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove as not using sub-scaffolds.

:return: annotationGroups
'''
fm = region.getFieldmodule()
fm.beginChange()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove beginChange and later endChange as these are called by caller Scaffold_base.generateMesh.
Note if we ever need them we now call opencmiss.utils.general ChangeManager(fieldmodule) as this guarantees endChange is called even if an exception occurs.

markerPoint = markerPoints.createNode(nodeIdentifier, markerTemplateInternal)
nodeIdentifier += 1
cache.setNode(markerPoint)
markerName.assignString(cache, 'APEX')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 'apex of left lung'. In the long run we want these to also be in interlex.

Comment on lines 822 to 934
remapEftNodeValueLabel(eft, [1, 2, 5, 6], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [1, 2, 5, 6], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [1, 2, 5, 6], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [1, 2, 5, 6], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 1, 2, 3, 4, 4, 5, 6]
remapEftLocalNodes(eft, 6, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi1AtXi2Zero: Failed to validate eft'
return eft

def createEftWedgeCollapseXi1AtXi2One(self):
'''
Create a tricubic hermite element field for a wedge element, where xi1 collapsed on xi2 = 1.
:return: Element field template
'''
eft = self.createEftBasic()

# remap parameters on xi2 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [3, 4, 7, 8], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [3, 7], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [3, 4, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [3, 4, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [3, 4, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [3, 4, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 2, 3, 3, 4, 5, 6, 6]
remapEftLocalNodes(eft, 6, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi1AtXi2One: Failed to validate eft'
return eft

def createEftWedgeCollapseXi2RightAtXi3One(self):
'''
Create a tricubic hermite element field for a wedge element, where xi2 collapsed on xi3 = 1 creating the
wedge elements. Top right Nodes are collapsed.
:return: Element field template
'''
eft = self.createEftBasic()

# remap parameters on xi3 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [])
remapEftNodeValueLabel(eft, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 2, 3, 4, 5, 6, 5, 6]
remapEftLocalNodes(eft, 6, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi2RightAtXi3One: Failed to validate eft'
return eft

def createEftWedgeCollapseXi2LeftAtXi3One(self):
'''
Create a tricubic hermite element field for a wedge element, where xi2 collapsed on xi3 = 1 creating the
wedge elements. Top left nodes are collapsed.
:return: Element field template
'''
eft = self.createEftBasic()
setEftScaleFactorIds(eft, [1], [])

# remap parameters on xi3 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 2, 3, 4, 5, 6, 5, 6]
remapEftLocalNodes(eft, 6, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi2LeftAtXi3One: Failed to validate eft'
return eft

def createEftWedgeCollapseXi1AtXi3One(self):
'''
Create a tricubic hermite element field for a wedge element, where xi1 collapsed on xi3 = 1.
:return: Element field template
'''
eft = self.createEftBasic()

# remap parameters on xi3 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [5, 7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 2, 3, 4, 5, 5, 6, 6]
remapEftLocalNodes(eft, 6, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi1AtXi3One: Failed to validate eft'
return eft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a think about how to manage all the permutations of these functions and ease of identifying which one to use.
I think these should be divided into just 3 functions based on which xi is collapsed, and pass the 2 local nodes which are 'rotated' 90 degrees on to their neighbours to use derivatives mapped to the next 'quadrant':
createEftWedgeCollapseXi1Quadrant(self, collapseNodes)
e.g.
eft = tricubicfactory.createEftWedgeCollapseXi1Quadrant([1, 5]) would do the same as createEftWedgeCollapseXi1AtXi2Zero
Inside the function it would look like:

eft = self.createEftBasic()
if (collapseNodes == [1,5]) or (collapseNodes == [2,6]):
    # remap nodes
    # & do common code such as zero derivatives on face, which is same for both these cases.
elif ...:
else:
    assert False, 'eftfactory_tricubichermite.createEftWedgeCollapseXiQuadrant not implemented for nodes ' + str(rotateNodes)
    eft = None
return eft

We don't have to implement all cases now, but there will be an obvious place to put them when we need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need both"createEftWedgeCollapseXi1QuadrantAtXi2Zero(self, collapseNodes)" and "createEftWedgeCollapseXi1QuadrantAtXi2One(self, collapseNodes)" since they have different node numbering and mapping. So, I decided to define one function named "createEftWedgeCollapseXi1QuadrantAtXi2Plane(self, collapseNodes, Xi2=None)" which include 4 cases:

  • Xi2=0 and collapseNodes = [1, 5]
  • Xi2=0 and collapseNodes = [2, 6]
  • Xi2=1 and collapseNodes = [3, 7]
  • Xi2=1 and collapseNodes = [4, 8]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also defining "createEftWedgeCollapseXi2QuadrantAtXi3Plane(self, collapseNodes, Xi3=None)" which includes following cases:

  • Xi3=0 and collapseNodes = [1, 2]
  • Xi3=0 and collapseNodes = [3, 4]
  • Xi3=1 and collapseNodes = [5, 6]
  • Xi3=1 and collapseNodes = [7, 8]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the third one as : "createEftWedgeCollapseXi1QuadrantAtXi3Plane"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, now I replaced 3 functions for creating wedge elements which cover 12 cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to mention AtXi3Plane, it's Xi2 which is being collapsed and the list of nodes say where.

Comment on lines 936 to 994
def createEftTetrahedronCollapseXi1Xi2AtXi3OneXi1AtXi2Zero(self):
'''
Create a tricubic hermite element field for a tetrahedron element, where xi1 and xi2 are collapsed on xi3 = 1
, and then, xi1 for nodes on both xi2 = 0 and xi3 = 0 is collapsed.
:return: Element field template
'''
eft = self.createEftBasic()
setEftScaleFactorIds(eft, [1], [])

# remap parameters on xi3 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [])
remapEftNodeValueLabel(eft, [5, 6], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])])
remapEftNodeValueLabel(eft, [7], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])])

# remap parameters on xi2 = 0 before collapsing nodes
remapEftNodeValueLabel(eft, [1, 2], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [1], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 1, 2, 3, 4, 4, 4, 4]
remapEftLocalNodes(eft, 4, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftTetrahedronCollapseXi1Xi2AtXi3OneXi1AtXi2Zero: Failed to validate eft'
return eft

def createEftTetrahedronCollapseXi1Xi2AtXi3OneXi1AtXi2One(self):
'''
Create a tricubic hermite element field for a tetrahedron element, where xi1 and xi2 are collapsed on xi3 = 1
, and then, xi1 for nodes on both xi2 = 1 and xi3 = 0 is collapsed.
:return: Element field template
'''
eft = self.createEftBasic()
setEftScaleFactorIds(eft, [1], [])

# remap parameters on xi3 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D_DS2, [])
remapEftNodeValueLabel(eft, [7, 8], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])])
remapEftNodeValueLabel(eft, [5], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])])

# remap parameters on xi2 = 1 before collapsing nodes
remapEftNodeValueLabel(eft, [3, 4], Node.VALUE_LABEL_D_DS1, [])
remapEftNodeValueLabel(eft, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])])

# zero cross derivative parameters
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS2, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS1DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D2_DS2DS3, [])
remapEftNodeValueLabel(eft, [5, 6, 7, 8], Node.VALUE_LABEL_D3_DS1DS2DS3, [])

ln_map = [1, 2, 3, 3, 4, 4, 4, 4]
remapEftLocalNodes(eft, 4, ln_map)
assert eft.validate(), 'eftfactory_tricubichermite.createEftTetrahedronCollapseXi1Xi2AtXi3OneXi1AtXi2One: Failed to validate eft'
return eft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the wedge, need a naming scheme to manage all these permutations, suggest for all tetrahedra collapsed in xi1xi2:
createEftTetrahedronCollapseXi1Xi2Quadrant(self, peakNode, sideNode)
where peakNode is the localNode where the whole of xi1, xi2 is collapsed on to (on either xi3=0 or xi3=1), and sideNode is the node at the other end of xi3 which has another node collapsed onto it.
e.g.
eft = tricubicfactory.createEftTetrahedronCollapseXi1Xi2Quadrant(8, 2) would do the same as createEftTetrahedronCollapseXi1Xi2AtXi3OneXi1AtXi2Zero

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defined one function named "createEftTetrahedronCollapseXi1Xi2QuadrantAtXi3One" which create four types of tetrahedron. Later, other cases can be added.

Copy link
Member

@rchristie rchristie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks.

@rchristie rchristie merged commit b5f578c into ABI-Software:master Nov 20, 2020
@zekh167 zekh167 deleted the lungs branch November 20, 2020 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants