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

Rescale derivatives for annulus mesh #100

Merged
merged 19 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 170 additions & 112 deletions src/scaffoldmaker/meshtypes/meshtype_3d_bladderurethra1.py

Large diffs are not rendered by default.

164 changes: 124 additions & 40 deletions src/scaffoldmaker/meshtypes/meshtype_3d_colon1.py

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/scaffoldmaker/meshtypes/meshtype_3d_colonsegment1.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def getName():
def getParameterSetNames():
return [
'Default',
'Cattle 1',
'Human 1',
'Mouse 1',
'Pig 1']
Expand Down Expand Up @@ -78,7 +79,19 @@ def getDefaultOptions(parameterSetName='Default'):
'Refine number of elements along segment' : 1,
'Refine number of elements through wall' : 1
}
if 'Mouse' in parameterSetName:
if 'Cattle' in parameterSetName:
options['Start inner radius'] = 10.5
options['End inner radius'] = 10.5
options['Corner inner radius factor'] = 0.0
options['Haustrum inner radius factor'] = 0.0
options['Segment length end derivative factor'] = 0.0
options['Segment length mid derivative factor'] = 0.0
options['Number of tenia coli'] = 1
options['Start tenia coli width'] = 3.0
options['End tenia coli width'] = 3.0
options['Tenia coli thickness'] = 0.0
options['Wall thickness'] = 3.02
elif 'Mouse' in parameterSetName:
options['Start inner radius'] = 0.94
options['End inner radius'] = 0.94
options['Corner inner radius factor'] = 0.0
Expand Down
476 changes: 281 additions & 195 deletions src/scaffoldmaker/utils/annulusmesh.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/scaffoldmaker/utils/eft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ def scaleEftNodeValueLabels(eft, localNodeIndexes, valueLabels, addScaleFactorIn
scaleFactorIndexes += addScaleFactorIndexes
eft.setTermScaling(f, t, scaleFactorIndexes)

def setEftScaleFactorIds(eft, generalScaleFactorIds, nodeScaleFactorIds):
def setEftScaleFactorIds(eft, globalScaleFactorIds, nodeScaleFactorIds):
'''
Set general followed by node scale factor identifiers.
'''
eft.setNumberOfLocalScaleFactors(len(generalScaleFactorIds) + len(nodeScaleFactorIds))
eft.setNumberOfLocalScaleFactors(len(globalScaleFactorIds) + len(nodeScaleFactorIds))
s = 1
for id in generalScaleFactorIds:
for id in globalScaleFactorIds:
eft.setScaleFactorType(s, Elementfieldtemplate.SCALE_FACTOR_TYPE_GLOBAL_GENERAL)
eft.setScaleFactorIdentifier(s, id)
s += 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bladder.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_bladder1(self):
self.assertTrue(region.isValid())

annotationGroups = MeshType_3d_bladder1.generateBaseMesh(region, options)
self.assertEqual(2, len(annotationGroups))
self.assertEqual(3, len(annotationGroups))
fieldmodule = region.getFieldmodule()
self.assertEqual(RESULT_OK, fieldmodule.defineAllFaces())
if annotationGroups is not None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cecum.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def test_cecum1(self):
fieldcache = fieldmodule.createFieldcache()
result, surfaceArea = surfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(surfaceArea, 65960.02821062482, delta=1.0E-6)
self.assertAlmostEqual(surfaceArea, 65959.34314511667, delta=1.0E-6)
result, volume = volumeField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(volume, 127893.74708048582, delta=1.0E-6)
self.assertAlmostEqual(volume, 127894.8597203706, delta=1.0E-6)

if __name__ == "__main__":
unittest.main()
14 changes: 7 additions & 7 deletions tests/test_colon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_colon1(self):
Test creation of colon scaffold.
"""
parameterSetNames = MeshType_3d_colon1.getParameterSetNames()
self.assertEqual(parameterSetNames, ["Default", "Human 1", "Human 2", "Mouse 1", "Mouse 2", "Pig 1", "Pig 2"])
self.assertEqual(parameterSetNames, ["Default", "Cattle 1", "Human 1", "Human 2", "Mouse 1", "Mouse 2", "Pig 1", "Pig 2"])
centralPathDefaultScaffoldPackages = {
'Test line': ScaffoldPackage(MeshType_1d_path1, {
'scaffoldSettings': {
Expand Down Expand Up @@ -112,14 +112,14 @@ def test_colon1(self):
coordinates = fieldmodule.findFieldByName("coordinates").castFiniteElement()
self.assertTrue(coordinates.isValid())
minimums, maximums = evaluateFieldNodesetRange(coordinates, nodes)
assertAlmostEqualList(self, minimums, [ 108.0250647983898, -36.876103983560014, -25.89741158325083 ], 1.0E-6)
assertAlmostEqualList(self, maximums, [ 185.46457506220003, 48.101157490744, 34.995316052158934 ], 1.0E-6)
assertAlmostEqualList(self, minimums, [ 108.03959866945482, -36.876103983560014, -25.93217903595996 ], 1.0E-6)
assertAlmostEqualList(self, maximums, [ 185.43446761757468, 48.07433517752282, 34.995316052158934 ], 1.0E-6)

flatCoordinates = fieldmodule.findFieldByName("flat coordinates").castFiniteElement()
self.assertTrue(flatCoordinates.isValid())
minimums, maximums = evaluateFieldNodesetRange(flatCoordinates, nodes)
assertAlmostEqualList(self, minimums, [ 0.0, 0.0, 0.0 ], 1.0E-6)
assertAlmostEqualList(self, maximums, [ 186.72988844629867, 77.4178187926561, 3.2000000000000006 ], 1.0E-6)
assertAlmostEqualList(self, maximums, [ 186.72988844629867, 75.79769125771575, 3.2000000000000006 ], 1.0E-6)

textureCoordinates = fieldmodule.findFieldByName("texture coordinates").castFiniteElement()
minimums, maximums = evaluateFieldNodesetRange(textureCoordinates, nodes)
Expand All @@ -136,10 +136,10 @@ def test_colon1(self):
fieldcache = fieldmodule.createFieldcache()
result, surfaceArea = surfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(surfaceArea, 14612.416788520026, delta=1.0E-6)
self.assertAlmostEqual(surfaceArea, 14623.340352853866, delta=1.0E-6)
result, volume = volumeField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(volume, 26826.069540921028, delta=1.0E-6)
self.assertAlmostEqual(volume, 26869.74823158621, delta=1.0E-6)

def test_mousecolon1(self):
"""
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_mousecolon1(self):
fieldcache = fieldmodule.createFieldcache()
result, flatSurfaceArea = flatSurfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(flatSurfaceArea, 652.2383326727861, delta=1.0E-6)
self.assertAlmostEqual(flatSurfaceArea, 629.440514706522, delta=1.0E-6)
result, textureSurfaceArea = textureSurfaceAreaField.evaluateReal(fieldcache, 1)
self.assertEqual(result, RESULT_OK)
self.assertAlmostEqual(textureSurfaceArea, 1.0, delta=1.0E-6)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_colonsegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_humancolonsegment1(self):
Test creation of human colon segment scaffold.
"""
parameterSetNames = MeshType_3d_colonsegment1.getParameterSetNames()
self.assertEqual(parameterSetNames, [ "Default", "Human 1", "Mouse 1", "Pig 1" ])
self.assertEqual(parameterSetNames, [ "Default", "Cattle 1", "Human 1", "Mouse 1", "Pig 1" ])
options = MeshType_3d_colonsegment1.getDefaultOptions("Human 1")
self.assertEqual(27, len(options))
self.assertEqual(0.0, options.get("Start phase"))
Expand Down