Skip to content

Commit

Permalink
made initial deformation scale factor to bee 10% of largest dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinsMechEng committed Jan 3, 2025
1 parent 61cca14 commit e5c1e50
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
15 changes: 15 additions & 0 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,8 @@ def process_finished(num):
self.min_iterations_old = 0
self.p.close()
self.p = None
# Restart deformation scale factor
self.INBFDeform.setValue(0)
def handle_stdout():
data = self.p.readAllStandardOutput()
stdout = bytes(data).decode("utf8")
Expand Down Expand Up @@ -1364,6 +1366,19 @@ def preview_results_click_2():
# Create a new source with the updated data
temp_source = paraview.simple.TrivialProducer()
temp_source.GetClientSideObject().SetOutput(output_data)
# Get initial scale factor
if self.INBFDeform.value() == 0:
# get the largest undeformed dimension
udims = [float(self.TParts.item(0,7).text()),float(self.TParts.item(0,8).text()),float(self.TParts.item(0,9).text())]
udimax = max(udims)
# get the max difference in each direction and the
dmaxX = max(abs(num) for num in diffX)
dmaxY = max(abs(num) for num in diffY)
dmaxZ = max(abs(num) for num in diffZ)
dmax = max([dmaxX,dmaxY,dmaxZ])
# get initial scale factor so that it the deformation is 10% of the largest dimension
initial_scale_factor = (0.1*udimax)/dmax
self.INBFDeform.setValue(initial_scale_factor)
# Scale the displacements
scale_factor = self.INBFDeform.value() # Adjust this value to change the scaling
scale_filter = paraview.simple.Calculator(Input=temp_source)
Expand Down
10 changes: 5 additions & 5 deletions python/FIERRO-GUI/fierro_gui/FIERRO_GUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
<number>1</number>
</property>
<property name="currentIndex">
<number>7</number>
<number>8</number>
</property>
<widget class="QWidget" name="TitleTool">
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -11645,7 +11645,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
Expand All @@ -11654,7 +11654,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
<double>0.000000000000000</double>
</property>
</widget>
</item>
Expand Down Expand Up @@ -11899,7 +11899,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<number>1</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
Expand All @@ -11908,7 +11908,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
<double>0.000000000000000</double>
</property>
</widget>
</item>
Expand Down
18 changes: 18 additions & 0 deletions python/FIERRO-GUI/fierro_gui/Homogenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,19 @@ def preview_results_click():
# Create a new source with the updated data
temp_source = paraview.simple.TrivialProducer()
temp_source.GetClientSideObject().SetOutput(output_data)
# Get initial scale factor
if self.INHDeform.value() == 0:
# get the largest undeformed dimension
udims = [float(self.TParts.item(0,7).text()),float(self.TParts.item(0,8).text()),float(self.TParts.item(0,9).text())]
udimax = max(udims)
# get the max difference in each direction and the
dmaxX = max(abs(num) for num in diffX)
dmaxY = max(abs(num) for num in diffY)
dmaxZ = max(abs(num) for num in diffZ)
dmax = max([dmaxX,dmaxY,dmaxZ])
# get initial scale factor so that it the deformation is 10% of the largest dimension
initial_scale_factor = (0.1*udimax)/dmax
self.INHDeform.setValue(initial_scale_factor)
# Scale the displacements
scale_factor = self.INHDeform.value() # Adjust this value to change the scaling
scale_filter = paraview.simple.Calculator(Input=temp_source)
Expand Down Expand Up @@ -1155,6 +1168,11 @@ def preview_results_click():
self.INResultRegion.currentIndexChanged.connect(preview_results_click)
self.INHDeform.valueChanged.connect(preview_results_click)

# Restart deformation scale factor
def restart_scale():
self.INHDeform.setValue(0)
self.INBCFile.currentIndexChanged.connect(restart_scale)

# Show results immediately when postprocessing tab is pressed
def show_results():
index = self.NavigationMenu.currentIndex()
Expand Down
10 changes: 5 additions & 5 deletions python/FIERRO-GUI/fierro_gui/ui_FIERRO_GUI.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'FIERRO_GUIGbeDCJ.ui'
## Form generated from reading UI file 'FIERRO_GUIgRWstX.ui'
##
## Created by: Qt User Interface Compiler version 6.6.0
##
Expand Down Expand Up @@ -5991,10 +5991,10 @@ def setupUi(self, MainWindow):
self.INHDeform.setButtonSymbols(QAbstractSpinBox.UpDownArrows)
self.INHDeform.setCorrectionMode(QAbstractSpinBox.CorrectToNearestValue)
self.INHDeform.setDecimals(1)
self.INHDeform.setMinimum(0.100000000000000)
self.INHDeform.setMinimum(0.000000000000000)
self.INHDeform.setMaximum(10000.000000000000000)
self.INHDeform.setSingleStep(1.000000000000000)
self.INHDeform.setValue(1.000000000000000)
self.INHDeform.setValue(0.000000000000000)

self.formLayout_20.setWidget(0, QFormLayout.FieldRole, self.INHDeform)

Expand Down Expand Up @@ -6113,10 +6113,10 @@ def setupUi(self, MainWindow):
self.INBFDeform.setButtonSymbols(QAbstractSpinBox.UpDownArrows)
self.INBFDeform.setCorrectionMode(QAbstractSpinBox.CorrectToNearestValue)
self.INBFDeform.setDecimals(1)
self.INBFDeform.setMinimum(0.100000000000000)
self.INBFDeform.setMinimum(0.000000000000000)
self.INBFDeform.setMaximum(10000.000000000000000)
self.INBFDeform.setSingleStep(1.000000000000000)
self.INBFDeform.setValue(1.000000000000000)
self.INBFDeform.setValue(0.000000000000000)

self.formLayout_21.setWidget(0, QFormLayout.FieldRole, self.INBFDeform)

Expand Down

0 comments on commit e5c1e50

Please sign in to comment.