Skip to content

Commit

Permalink
Continue, add periodic partner selector and obj
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Bergh committed May 31, 2022
1 parent 9f6c0fb commit 2731f7c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CfdCaseWriterFoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ def processFluidProperties(self):

def processBoundaryConditions(self):
""" Compute any quantities required before case build """
settings = self.settings
# Copy keys so that we can delete while iterating
settings = self.settings
bc_names = list(settings['boundaries'].keys())
for bc_name in bc_names:
bc = settings['boundaries'][bc_name]
Expand Down Expand Up @@ -310,6 +310,7 @@ def processBoundaryConditions(self):
raise RuntimeError
except (SystemError, RuntimeError):
raise RuntimeError(str(bc['DirectionFace']) + " is not a valid, planar face.")

if settings['solver']['SolverName'] in ['simpleFoam', 'porousSimpleFoam', 'pimpleFoam', 'SRFSimpleFoam']:
bc['KinematicPressure'] = bc['Pressure']/settings['fluidProperties'][0]['Density']

Expand Down Expand Up @@ -361,6 +362,7 @@ def processBoundaryConditions(self):
if settings['boundaries'].get('defaultFaces'):
raise ValueError("More than one default boundary defined")
settings['boundaries']['defaultFaces'] = bc

if not settings['boundaries'].get('defaultFaces'):
settings['boundaries']['defaultFaces'] = {
'BoundaryType': 'wall',
Expand Down
2 changes: 2 additions & 0 deletions CfdFluidBoundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def initProperties(self, obj):
"Periodic", "Axis of rotational for rotational periodics")
addObjectProperty(obj, 'PeriodicSeparationVector', FreeCAD.Vector(0, 0, 0), "App::PropertyPosition",
"Periodic", "Separation vector for translational periodics")
addObjectProperty(obj, 'PeriodicPartner', '', "App::PropertyString", "Periodic",
"Partner patch for the current periodic")

# Turbulence
all_turb_specs = []
Expand Down
14 changes: 13 additions & 1 deletion _TaskPanelCfdFluidBoundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import FreeCAD
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtGui
from PySide import QtGui, QtCore
from PySide.QtGui import QFormLayout
import CfdTools
from CfdTools import getQuantity, setQuantity, indexOrDefault, storeIfChanged
Expand Down Expand Up @@ -116,6 +116,16 @@ def __init__(self, obj, physics_model, material_objs):
self.form.buttonGroupPeriodic.setId(self.form.rb_rotational_periodic, 0)
self.form.buttonGroupPeriodic.setId(self.form.rb_translational_periodic, 1)

boundary_patches = CfdTools.getCfdBoundaryGroup(self.analysis_obj)
periodic_patches = []
for patch in boundary_patches:
if patch.BoundarySubType == 'cyclicAMI' and patch.Label != self.obj.Label:
periodic_patches.append(patch.Label)

self.form.comboBoxPeriodicPartner.addItems(periodic_patches)
pi = self.form.comboBoxPeriodicPartner.findText(self.obj.PeriodicPartner, QtCore.Qt.MatchFixedString)
self.form.comboBoxPeriodicPartner.setCurrentIndex(pi)

self.form.rb_rotational_periodic.setChecked(self.obj.RotationalPeriodic)
self.form.rb_translational_periodic.setChecked(not self.obj.RotationalPeriodic)
setQuantity(self.form.input_corx, self.obj.PeriodicCentreOfRotation.x)
Expand Down Expand Up @@ -447,6 +457,8 @@ def accept(self):
self.form.input_sepz.property("quantity").Value)
storeIfChanged(self.obj, 'PeriodicSeparationVector', separation_vector)

storeIfChanged(self.obj, 'PeriodicPartner', self.form.comboBoxPeriodicPartner.currentText())

# Turbulence
if self.turb_model in CfdFluidBoundary.TURBULENT_INLET_SPEC:
turb_index = self.form.comboTurbulenceSpecification.currentIndex()
Expand Down
12 changes: 11 additions & 1 deletion core/gui/TaskPanelCfdFluidBoundary.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,16 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Partner patch</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxPeriodicPartner"/>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -2109,7 +2119,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroupPorous"/>
<buttongroup name="buttonGroupPeriodic"/>
<buttongroup name="buttonGroupPorous"/>
</buttongroups>
</ui>
10 changes: 10 additions & 0 deletions data/defaults/constant/polyMesh/_boundaryPatches
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
{
type cyclic;
}
%:cyclicAMI
%(0%)_master
{
type patch;
}

%(0%)_slave
{
type patch;
}
%:empty
%(0%)
{
Expand Down

0 comments on commit 2731f7c

Please sign in to comment.