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

Add shell layers #173

Merged
merged 1 commit into from
Mar 10, 2022
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
40 changes: 23 additions & 17 deletions src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from opencmiss.utils.zinc.field import findOrCreateFieldCoordinates
from scaffoldmaker.annotation.annotationgroup import AnnotationGroup
from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base
from scaffoldmaker.utils import vector
from scaffoldmaker.utils.meshrefinement import MeshRefinement
from scaffoldmaker.utils.spheremesh import SphereMesh, SphereShape
from scaffoldmaker.utils import vector


class MeshType_3d_solidsphere2(Scaffold_base):
Expand All @@ -30,11 +30,11 @@ def getDefaultOptions(cls, parameterSetName='Default'):
'Number of elements across axis 2': 4,
'Number of elements across axis 3': 4,
'Number of elements across shell': 0,
'Shell element thickness proportion': 1.0,
'Number of elements across transition': 1,
'Radius1': 1.0,
'Radius2': 1.0,
'Radius3': 1.0,
'Shell element thickness proportion': 1.0,
'Range of elements required in direction 1': [0, 4],
'Range of elements required in direction 2': [0, 4],
'Range of elements required in direction 3': [0, 4],
Expand All @@ -51,12 +51,12 @@ def getOrderedOptionNames():
'Number of elements across axis 1',
'Number of elements across axis 2',
'Number of elements across axis 3',
# 'Number of elements across shell',
'Number of elements across shell',
'Shell element thickness proportion',
# 'Number of elements across transition',
'Radius1',
'Radius2',
'Radius3',
# 'Shell element thickness proportion',
'Range of elements required in direction 1',
'Range of elements required in direction 2',
'Range of elements required in direction 3',
Expand Down Expand Up @@ -96,14 +96,16 @@ def checkOptions(cls, options):
options['Box derivatives'] = [1, 2, 3]

for i in range(1, 4):
if options['Range of elements required in direction {}'.format(i)][1] == \
options['Number of elements across axis {}'.format(i)] - 1:
if options['Range of elements required in direction {}'.format(i)][1] >= \
options['Number of elements across axis {}'.format(i)] - 1\
- options['Number of elements across shell']:
options['Range of elements required in direction {}'.format(i)][1] = \
options['Number of elements across axis {}'.format(i)]

nm = 4
for i in range(1, nm):
if options['Range of elements required in direction {}'.format(i)][0] == 1:
if options['Range of elements required in direction {}'.format(i)][0] <= 1 + \
options['Number of elements across shell']:
options['Range of elements required in direction {}'.format(i)][0] = 0

maxelems = [options['Number of elements across axis 1'],
Expand All @@ -114,25 +116,29 @@ def checkOptions(cls, options):
options['Range of elements required in direction 3']]
for i in range(3):
if ranges[i][1] > maxelems[i] or ranges[i][1] <= max(1, ranges[i][0]):
dependentChanges = True
ranges[i][1] = maxelems[i]
for i in range(3):
if ranges[i][0] >= min(maxelems[i] - 1, ranges[i][1]) or ranges[i][0] < 1:
dependentChanges = True
ranges[i][0] = 0

options['Range of elements required in direction 1'] = ranges[0]
options['Range of elements required in direction 2'] = ranges[1]
options['Range of elements required in direction 3'] = ranges[2]

# 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
elementsCount_min = min(options['Number of elements across axis 1'],
options['Number of elements across axis 2'],
options['Number of elements across axis 3'],)

max_shell_elements = elementsCount_min//2 - 2

if options['Number of elements across shell'] > max_shell_elements:
dependentChanges = True
options['Number of elements across shell'] = max_shell_elements

if options['Shell element thickness proportion'] < 0.15:
options['Shell element thickness proportion'] = 1.0

return dependentChanges

Expand Down
2 changes: 1 addition & 1 deletion src/scaffoldmaker/scaffolds.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def __init__(self):
MeshType_3d_lung1,
MeshType_3d_ostium1,
MeshType_3d_smallintestine1,
MeshType_3d_solidcylinder1,
MeshType_3d_solidsphere1,
MeshType_3d_solidsphere2,
MeshType_3d_solidcylinder1,
MeshType_3d_sphereshell1,
MeshType_3d_sphereshellseptum1,
MeshType_3d_stellate1,
Expand Down
Loading