def __init__(self, obj): self.obj = obj self.analysis_obj = CfdTools.getActiveAnalysis() self.physics_obj = CfdTools.getPhysicsModel(self.analysis_obj) ui_path = os.path.join(CfdTools.getModulePath(), 'Gui', "TaskPanelCfdReportingFunctions.ui") self.form = FreeCADGui.PySideUic.loadUi(ui_path) # Function Object types self.form.comboFunctionObjectType.addItems(CfdReportingFunction.OBJECT_NAMES) self.form.comboFunctionObjectType.currentIndexChanged.connect(self.comboFunctionObjectTypeChanged) self.form.inputReferencePressure.setToolTip("Reference pressure") self.form.inputWriteFields.setToolTip("Write output fields") self.form.inputCentreOfRotationx.setToolTip("Centre of rotation vector for moments") self.form.inputLiftDirectionx.setToolTip("Lift direction vector") self.form.inputDragDirectionx.setToolTip("Drag direction vector") self.form.inputMagnitudeUInf.setToolTip("Velocity magnitude reference") self.form.inputReferenceDensity.setToolTip("Density reference") self.form.inputLengthRef.setToolTip("Length reference") self.form.inputAreaRef.setToolTip("Area reference") self.form.inputNBins.setToolTip("Number of bins") self.form.inputDirectionx.setToolTip("Binning direction") self.form.inputCumulative.setToolTip("Cumulative") self.form.cb_patch_list.setToolTip("Patch (BC) group to monitor") self.list_of_bcs = [bc.Label for bc in CfdTools.getCfdBoundaryGroup(self.analysis_obj)] self.form.cb_patch_list.addItems(self.list_of_bcs) self.load() self.updateUI()
def __init__(self, analysis_obj): self.case_folder = None self.mesh_file_name = None self.template_path = None self.analysis_obj = analysis_obj self.solver_obj = CfdTools.getSolver(analysis_obj) self.physics_model = CfdTools.getPhysicsModel(analysis_obj) self.mesh_obj = CfdTools.getMesh(analysis_obj) self.material_objs = CfdTools.getMaterials(analysis_obj) self.bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) self.initial_conditions = CfdTools.getInitialConditions(analysis_obj) self.reporting_functions = CfdTools.getReportingFunctionsGroup( analysis_obj) self.scalar_transport_objs = CfdTools.getScalarTransportFunctionsGroup( analysis_obj) self.porous_zone_objs = CfdTools.getPorousZoneObjects(analysis_obj) self.initialisation_zone_objs = CfdTools.getInitialisationZoneObjects( analysis_obj) self.zone_objs = CfdTools.getZoneObjects(analysis_obj) self.dynamic_mesh_refinement_obj = CfdTools.getDynamicMeshAdaptation( analysis_obj) self.mesh_generated = False self.working_dir = CfdTools.getOutputPath(self.analysis_obj) self.progressCallback = None self.settings = None
def setEdit(self, vobj, mode): analysis_object = CfdTools.getParentAnalysisObject(self.Object) if analysis_object is None: CfdTools.cfdErrorBox("No parent analysis object found") return False physics_model = CfdTools.getPhysicsModel(analysis_object) if not physics_model: CfdTools.cfdErrorBox("Analysis object must have a physics object") return False boundaries = CfdTools.getCfdBoundaryGroup(analysis_object) material_objs = CfdTools.getMaterials(analysis_object) import importlib importlib.reload(TaskPanelCfdInitialiseInternalFlowField) self.taskd = TaskPanelCfdInitialiseInternalFlowField.TaskPanelCfdInitialiseInternalFlowField( self.Object, physics_model, boundaries, material_objs) self.taskd.obj = vobj.Object FreeCADGui.Control.showDialog(self.taskd) return True
def accept(self): FreeCADGui.Selection.removeObserver(self) doc = FreeCADGui.getDocument(self.obj.Document) doc.resetEdit() # Type index = self.form.comboFunctionObjectType.currentIndex() storeIfChanged(self.obj, 'ReportingFunctionType', CfdReportingFunction.OBJECT_NAMES[self.form.comboFunctionObjectType.currentIndex()]) bcs = CfdTools.getCfdBoundaryGroup(self.analysis_obj) bc = bcs[self.form.cb_patch_list.currentIndex()] if (not self.obj.Patch and bc) or (bc and bc.Name != self.obj.Patch.Name): FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.Patch " "= FreeCAD.ActiveDocument.{}".format(self.obj.Name, bc.Name)) # Force object storeIfChanged(self.obj, 'ReferenceDensity', getQuantity(self.form.inputReferenceDensity)) storeIfChanged(self.obj, 'ReferencePressure', getQuantity(self.form.inputReferencePressure)) storeIfChanged(self.obj, 'WriteFields', self.form.inputWriteFields.isChecked()) centre_of_rotation = FreeCAD.Vector( self.form.inputCentreOfRotationx.property("quantity").Value, self.form.inputCentreOfRotationy.property("quantity").Value, self.form.inputCentreOfRotationz.property("quantity").Value) storeIfChanged(self.obj, 'CentreOfRotation', centre_of_rotation) # # Coefficient object lift_dir = FreeCAD.Vector( self.form.inputLiftDirectionx.property("quantity").Value, self.form.inputLiftDirectiony.property("quantity").Value, self.form.inputLiftDirectionz.property("quantity").Value) storeIfChanged(self.obj, 'Lift', lift_dir) drag_dir = FreeCAD.Vector( self.form.inputDragDirectionx.property("quantity").Value, self.form.inputDragDirectiony.property("quantity").Value, self.form.inputDragDirectionz.property("quantity").Value) storeIfChanged(self.obj, 'Drag', drag_dir) storeIfChanged(self.obj, 'MagnitudeUInf', getQuantity(self.form.inputMagnitudeUInf)) storeIfChanged(self.obj, 'LengthRef', getQuantity(self.form.inputLengthRef)) storeIfChanged(self.obj, 'AreaRef', getQuantity(self.form.inputAreaRef)) # # Spatial binning storeIfChanged(self.obj, 'NBins', self.form.inputNBins.value()) bins_direction = FreeCAD.Vector( self.form.inputDirectionx.property("quantity").Value, self.form.inputDirectiony.property("quantity").Value, self.form.inputDirectionz.property("quantity").Value) storeIfChanged(self.obj, 'Direction', bins_direction) storeIfChanged(self.obj, 'Cumulative', self.form.inputCumulative.isChecked()) # Probe info storeIfChanged(self.obj, 'SampleFieldName', self.form.inputFieldName.text()) probe_position = FreeCAD.Vector( self.form.inputProbeLocx.property("quantity").Value, self.form.inputProbeLocy.property("quantity").Value, self.form.inputProbeLocz.property("quantity").Value) storeIfChanged(self.obj, 'ProbePosition', probe_position) # Finalise FreeCADGui.doCommand("FreeCAD.ActiveDocument.recompute()")
def accept(self): self.analysis_obj.NeedsMeshRewrite = self.NeedsMeshRewriteOrig self.analysis_obj.NeedsCaseRewrite = self.NeedsCaseRewriteOrig if self.obj.Label.startswith("CfdFluidBoundary"): storeIfChanged(self.obj, 'Label', self.obj.BoundaryType) # Type if self.obj.BoundaryType != self.BoundaryTypeOrig: FreeCADGui.doCommand( "FreeCAD.ActiveDocument.{}.BoundaryType = '{}'".format(self.obj.Name, self.obj.BoundaryType)) if self.obj.BoundarySubType != self.BoundarySubTypeOrig: FreeCADGui.doCommand( "FreeCAD.ActiveDocument.{}.BoundarySubType = '{}'".format(self.obj.Name, self.obj.BoundarySubType)) storeIfChanged(self.obj, 'ThermalBoundaryType', CfdFluidBoundary.THERMAL_BOUNDARY_TYPES[self.form.comboThermalBoundaryType.currentIndex()]) # Velocity storeIfChanged(self.obj, 'VelocityIsCartesian', self.form.radioButtonCart.isChecked()) storeIfChanged(self.obj, 'Ux', getQuantity(self.form.inputCartX)) storeIfChanged(self.obj, 'Uy', getQuantity(self.form.inputCartY)) storeIfChanged(self.obj, 'Uz', getQuantity(self.form.inputCartZ)) storeIfChanged(self.obj, 'VelocityMag', getQuantity(self.form.inputVelocityMag)) storeIfChanged(self.obj, 'DirectionFace', self.form.lineDirection.text()) storeIfChanged(self.obj, 'ReverseNormal', self.form.checkReverse.isChecked()) storeIfChanged(self.obj, 'MassFlowRate', getQuantity(self.form.inputMassFlowRate)) storeIfChanged(self.obj, 'VolFlowRate', getQuantity(self.form.inputVolFlowRate)) # Pressure storeIfChanged(self.obj, 'Pressure', getQuantity(self.form.inputPressure)) # Wall storeIfChanged(self.obj, 'SlipRatio', getQuantity(self.form.inputSlipRatio)) # Thermal storeIfChanged(self.obj, 'Temperature', getQuantity(self.form.inputTemperature)) storeIfChanged(self.obj, 'HeatFlux', getQuantity(self.form.inputHeatFlux)) storeIfChanged(self.obj, 'HeatTransferCoeff', getQuantity(self.form.inputHeatTransferCoeff)) # Turbulence if self.turb_model in CfdFluidBoundary.TURBULENT_INLET_SPEC: turb_index = self.form.comboTurbulenceSpecification.currentIndex() storeIfChanged(self.obj, 'TurbulenceInletSpecification', CfdFluidBoundary.TURBULENT_INLET_SPEC[self.turb_model][1][turb_index]) else: storeIfChanged(self.obj, 'TurbulenceInletSpecification', self.obj.TurbulenceInletSpecification) storeIfChanged(self.obj, 'TurbulentKineticEnergy', getQuantity(self.form.inputKineticEnergy)) storeIfChanged(self.obj, 'SpecificDissipationRate', getQuantity(self.form.inputSpecificDissipationRate)) storeIfChanged(self.obj, 'DissipationRate', getQuantity(self.form.inputDissipationRate)) storeIfChanged(self.obj, 'NuTilda', getQuantity(self.form.inputNuTilda)) storeIfChanged(self.obj, 'Intermittency', getQuantity(self.form.inputGammaInt)) storeIfChanged(self.obj, 'ReThetat', getQuantity(self.form.inputReThetat)) storeIfChanged(self.obj, 'TurbulentViscosity', getQuantity(self.form.inputTurbulentViscosity)) storeIfChanged(self.obj, 'kEqnTurbulentKineticEnergy', getQuantity(self.form.inputKineticEnergy)) storeIfChanged(self.obj, 'kEqnTurbulentViscosity', getQuantity(self.form.inputTurbulentViscosity)) storeIfChanged(self.obj, 'TurbulenceIntensityPercentage', getQuantity(self.form.inputIntensity)) storeIfChanged(self.obj, 'TurbulenceLengthScale', getQuantity(self.form.inputLengthScale)) # Multiphase storeIfChanged(self.obj, 'VolumeFractions', self.alphas) # Porous storeIfChanged(self.obj, 'PorousBaffleMethod', CfdFluidBoundary.POROUS_METHODS[self.form.buttonGroupPorous.checkedId()]) storeIfChanged(self.obj, 'PressureDropCoeff', getQuantity(self.form.inputPressureDropCoeff)) storeIfChanged(self.obj, 'ScreenWireDiameter', getQuantity(self.form.inputWireDiameter)) storeIfChanged(self.obj, 'ScreenSpacing', getQuantity(self.form.inputSpacing)) # Only update references if changed if self.obj.ShapeRefs != self.ShapeRefsOrig: refstr = "FreeCAD.ActiveDocument.{}.ShapeRefs = [\n".format(self.obj.Name) refstr += ',\n'.join( "(FreeCAD.ActiveDocument.getObject('{}'), {})".format(ref[0].Name, ref[1]) for ref in self.obj.ShapeRefs) refstr += "]" FreeCADGui.doCommand(refstr) # Default boundary defaultBoundary = self.form.checkBoxDefaultBoundary.isChecked() storeIfChanged(self.obj, 'DefaultBoundary', defaultBoundary) if defaultBoundary: # Deactivate previous default boundary, if any boundaries = CfdTools.getCfdBoundaryGroup(CfdTools.getParentAnalysisObject(self.obj)) for b in boundaries: if b.Name != self.obj.Name and b.DefaultBoundary: FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.DefaultBoundary = False".format(b.Name)) FreeCADGui.doCommand("FreeCAD.ActiveDocument.recompute()") doc = FreeCADGui.getDocument(self.obj.Document) doc.resetEdit()
def processRefinements(self): """ Process mesh refinements """ mr_objs = CfdTools.getMeshRefinementObjs(self.mesh_obj) cf_settings = self.cf_settings cf_settings['MeshRegions'] = {} cf_settings['BoundaryLayers'] = {} cf_settings['InternalRegions'] = {} snappy_settings = self.snappy_settings snappy_settings['MeshRegions'] = {} snappy_settings['BoundaryLayers'] = {} snappy_settings['InternalRegions'] = {} # Make list of all faces in meshed shape with original index mesh_face_list = list( zip(self.mesh_obj.Part.Shape.Faces, range(len(self.mesh_obj.Part.Shape.Faces)))) # Make list of all boundary references CfdTools.cfdMessage("Matching boundary patches\n") boundary_face_list = [] bc_group = None analysis_obj = CfdTools.getParentAnalysisObject(self.mesh_obj) if not analysis_obj: analysis_obj = CfdTools.getActiveAnalysis() if analysis_obj: bc_group = CfdTools.getCfdBoundaryGroup(analysis_obj) for bc_id, bc_obj in enumerate(bc_group): for ri, ref in enumerate(bc_obj.ShapeRefs): try: bf = CfdTools.resolveReference(ref) except RuntimeError as re: raise RuntimeError( "Error processing boundary condition {}: {}".format( bc_obj.Label, str(re))) for si, s in enumerate(bf): boundary_face_list += [(sf, (bc_id, ri, si)) for sf in s[0].Faces] # Match them up to faces in the main geometry bc_matched_faces = CfdTools.matchFaces(boundary_face_list, mesh_face_list) # Check for and filter duplicates bc_match_per_shape_face = [-1] * len(mesh_face_list) for k in range(len(bc_matched_faces)): match = bc_matched_faces[k][1] prev_k = bc_match_per_shape_face[match] if prev_k >= 0: nb, ri, si = bc_matched_faces[k][0] nb2, ri2, si2 = bc_matched_faces[prev_k][0] bc = bc_group[nb] bc2 = bc_group[nb2] CfdTools.cfdWarning( "Boundary '{}' reference {}:{} also assigned as " "boundary '{}' reference {}:{} - ignoring duplicate\n". format(bc.Label, bc.ShapeRefs[ri][0].Name, bc.ShapeRefs[ri][1][si], bc2.Label, bc.ShapeRefs[ri][0].Name, bc.ShapeRefs[ri][1][si])) else: bc_match_per_shape_face[match] = k # Match relevant mesh regions to the shape being meshed: boundary layer mesh regions for cfMesh, # all surface mesh refinements for snappyHexMesh, and extrusion patches for all meshers. # For cfMesh, surface mesh refinements are written as separate surfaces so need not be matched CfdTools.cfdMessage("Matching mesh refinement regions\n") mr_face_list = [] for mr_id, mr_obj in enumerate(mr_objs): if mr_obj.Extrusion or ( self.mesh_obj.MeshUtility == 'cfMesh' and not mr_obj.Internal and mr_obj.NumberLayers > 0) or ( self.mesh_obj.MeshUtility == 'snappyHexMesh' and not mr_obj.Internal): for ri, r in enumerate(mr_obj.ShapeRefs): try: bf = CfdTools.resolveReference(r) except RuntimeError as re: raise RuntimeError( "Error processing mesh refinement {}: {}".format( mr_obj.Label, str(re))) for si, s in enumerate(bf): mr_face_list += [(f, (mr_id, ri, si)) for f in s[0].Faces] # Match them up to the primary geometry mr_matched_faces = CfdTools.matchFaces(mr_face_list, mesh_face_list) # Check for and filter duplicates mr_match_per_shape_face = [-1] * len(mesh_face_list) for k in range(len(mr_matched_faces)): match = mr_matched_faces[k][1] prev_k = mr_match_per_shape_face[match] if prev_k >= 0: nr, ri, si = mr_matched_faces[k][0] nr2, ri2, si2 = mr_matched_faces[prev_k][0] CfdTools.cfdWarning( "Mesh refinement '{}' reference {}:{} also assigned as " "mesh refinement '{}' reference {}:{} - ignoring duplicate\n" .format(mr_objs[nr].Label, mr_objs[nr].ShapeRefs[ri][0].Name, mr_objs[nr].ShapeRefs[ri][1][si], mr_objs[nr2].Label, mr_objs[nr2].ShapeRefs[ri2][0].Name, mr_objs[nr2].ShapeRefs[ri2][1][si2])) else: mr_match_per_shape_face[match] = k self.patch_faces = [] self.patch_names = [] for k in range(len(bc_group) + 1): self.patch_faces.append([]) self.patch_names.append([]) for l in range(len(mr_objs) + 1): self.patch_faces[k].append([]) self.patch_names[k].append("patch_" + str(k) + "_" + str(l)) for i in range(len(mesh_face_list)): k = bc_match_per_shape_face[i] l = mr_match_per_shape_face[i] nb = -1 nr = -1 if k >= 0: nb, bri, bsi = bc_matched_faces[k][0] if l >= 0: nr, rri, ssi = mr_matched_faces[l][0] self.patch_faces[nb + 1][nr + 1].append(i) # For gmsh, match mesh refinement with vertices in original mesh mr_matched_vertices = [] if self.mesh_obj.MeshUtility == 'gmsh': # Make list of all vertices in meshed shape with original index mesh_vertices_list = list( zip(self.mesh_obj.Part.Shape.Vertexes, range(len(self.mesh_obj.Part.Shape.Vertexes)))) CfdTools.cfdMessage("Matching mesh refinements\n") mr_vertices_list = [] for mr_id, mr_obj in enumerate(mr_objs): if not mr_obj.Internal: for ri, r in enumerate(mr_obj.ShapeRefs): try: bf = CfdTools.resolveReference(r) except RuntimeError as re: raise RuntimeError( "Error processing mesh refinement {}: {}". format(mr_obj.Label, str(re))) for si, s in enumerate(bf): mr_vertices_list += [(v, (mr_id, ri, si)) for v in s[0].Vertexes] mr_matched_vertices = CfdTools.matchFaces(mr_vertices_list, mesh_vertices_list) self.ele_length_map = {} self.ele_node_map = {} # For snappyHexMesh, also match surface mesh refinements to the boundary conditions, to identify boundary # conditions on supplementary geometry defined by the surface mesh refinements # Also matches baffles to surface mesh refinements bc_mr_matched_faces = [] if self.mesh_obj.MeshUtility == 'snappyHexMesh': bc_mr_matched_faces = CfdTools.matchFaces(boundary_face_list, mr_face_list) # Handle baffles for bc_id, bc_obj in enumerate(bc_group): if bc_obj.BoundaryType == 'baffle': baffle_matches = [ m for m in bc_mr_matched_faces if m[0][0] == bc_id ] mr_match_per_baffle_ref = [] for r in bc_obj.ShapeRefs: mr_match_per_baffle_ref += [[-1] * len(r[1])] for m in baffle_matches: mr_match_per_baffle_ref[m[0][1]][m[0][2]] = m[1][0] # For each mesh region, the refs that are part of this baffle baffle_patch_refs = [[] for ri in range(len(mr_objs) + 1)] for ri, mr in enumerate(mr_match_per_baffle_ref): for si, mri in enumerate(mr_match_per_baffle_ref[ri]): baffle_patch_refs[mri + 1].append( (bc_obj.ShapeRefs[ri][0], (bc_obj.ShapeRefs[ri][1][si], ))) # Write these geometries for ri, refs in enumerate(baffle_patch_refs): try: shape = CfdTools.makeShapeFromReferences(refs) except RuntimeError as re: raise RuntimeError( "Error processing baffle {}: {}".format( bc_obj.Label, str(re))) solid_name = bc_obj.Name + "_" + str(ri) if shape: CfdTools.cfdMessage( "Triangulating baffle {}, section {}\n".format( bc_obj.Label, ri)) writeSurfaceMeshFromShape(shape, self.triSurfaceDir, solid_name, self.mesh_obj) if ri > 0: # The parts of the baffle corresponding to a surface mesh region obj mr_obj = mr_objs[ri - 1] refinement_level = CfdTools.relLenToRefinementLevel( mr_obj.RelativeLength) edge_level = CfdTools.relLenToRefinementLevel( mr_obj.RegionEdgeRefinement) else: # The parts of the baffle with no refinement obj refinement_level = 0 edge_level = 0 snappy_settings['MeshRegions'][solid_name] = { 'RefinementLevel': refinement_level, 'EdgeRefinementLevel': edge_level, 'MaxRefinementLevel': max(refinement_level, edge_level), 'Baffle': True } for mr_id, mr_obj in enumerate(mr_objs): Internal = mr_obj.Internal mr_rellen = mr_obj.RelativeLength if mr_rellen > 1.0: mr_rellen = 1.0 FreeCAD.Console.PrintError( "The mesh refinement region '{}' should not use a relative length greater " "than unity.\n".format(mr_obj.Name)) elif mr_rellen < 0.001: mr_rellen = 0.001 # Relative length should not be less than 0.1% of base length FreeCAD.Console.PrintError( "The mesh refinement region '{}' should not use a relative length smaller " "than 0.001.\n".format(mr_obj.Name)) if self.mesh_obj.MeshUtility == 'gmsh': # Generate element maps for gmsh if not Internal: mesh_vertex_idx = [ mf[1] for mf in mr_matched_vertices if mf[0][0] == mr_id ] self.ele_length_map[mr_obj.Name] = mr_rellen * self.clmax self.ele_node_map[mr_obj.Name] = mesh_vertex_idx else: # Find any matches with boundary conditions; mark those matching baffles for removal bc_matches = [ m for m in bc_mr_matched_faces if m[1][0] == mr_id ] bc_match_per_mr_ref = [] for ri, r in enumerate(mr_obj.ShapeRefs): bc_match_per_mr_ref.append([-1] * len(r[1])) for m in bc_matches: bc_match_per_mr_ref[m[1][1]][m[1][2]] = -2 if bc_group[ m[0][0]].BoundaryType == 'baffle' else m[0][0] # Unmatch those in primary geometry main_geom_matches = [ m for m in mr_matched_faces if m[0][0] == mr_id ] for m in main_geom_matches: bc_match_per_mr_ref[m[0][1]][m[0][2]] = -1 # For each boundary, the refs that are part of this mesh region mr_patch_refs = [[] for ri in range(len(bc_group) + 1)] for ri, m in enumerate(bc_match_per_mr_ref): for si, bci in enumerate(m): if bci > -2: mr_patch_refs[bci + 1].append( (mr_obj.ShapeRefs[ri][0], (mr_obj.ShapeRefs[ri][1][si], ))) # Loop over and write the sub-sections of this mesh object for bi in range(len(mr_patch_refs)): if len(mr_patch_refs[bi]) and not mr_obj.Extrusion: if bi == 0: mr_patch_name = mr_obj.Name else: mr_patch_name = self.patch_names[bi][mr_id + 1] CfdTools.cfdMessage( "Triangulating mesh refinement region {}, section {}\n" .format(mr_obj.Label, bi)) try: shape = CfdTools.makeShapeFromReferences( mr_patch_refs[bi]) except RuntimeError as re: raise RuntimeError( "Error processing mesh refinement region {}: {}" .format(mr_obj.Label, str(re))) if shape: writeSurfaceMeshFromShape(shape, self.triSurfaceDir, mr_patch_name, self.mesh_obj) refinement_level = CfdTools.relLenToRefinementLevel( mr_obj.RelativeLength) if self.mesh_obj.MeshUtility == 'cfMesh': if not Internal: cf_settings['MeshRegions'][mr_patch_name] = { 'RefinementLevel': refinement_level, 'RefinementThickness': self.scale * Units.Quantity( mr_obj.RefinementThickness).Value, } else: cf_settings['InternalRegions'][mr_obj.Name] = { 'RefinementLevel': refinement_level, 'RelativeLength': mr_rellen * self.clmax * self.scale } elif self.mesh_obj.MeshUtility == 'snappyHexMesh': if not Internal: edge_level = CfdTools.relLenToRefinementLevel( mr_obj.RegionEdgeRefinement) snappy_settings['MeshRegions'][ mr_patch_name] = { 'RefinementLevel': refinement_level, 'EdgeRefinementLevel': edge_level, 'MaxRefinementLevel': max(refinement_level, edge_level), 'Baffle': False } else: snappy_settings['InternalRegions'][ mr_patch_name] = { 'RefinementLevel': refinement_level } # In addition, for cfMesh and SnappyHesMesh, record matched boundary layer patches if (self.mesh_obj.MeshUtility == 'cfMesh' or self.mesh_obj.MeshUtility == 'snappyHexMesh') \ and mr_obj.NumberLayers > 0 and not Internal and not mr_obj.Extrusion: for k in range(len(self.patch_faces)): if len(self.patch_faces[k][mr_id + 1]): # Limit expansion ratio to greater than 1.0 and less than 1.2 expratio = mr_obj.ExpansionRatio expratio = min(1.2, max(1.0, expratio)) if self.mesh_obj.MeshUtility == 'cfMesh': cf_settings['BoundaryLayers'][self.patch_names[k][mr_id + 1]] = \ { 'NumberLayers': mr_obj.NumberLayers, 'ExpansionRatio': expratio, 'FirstLayerHeight': self.scale * Units.Quantity(mr_obj.FirstLayerHeight).Value } elif self.mesh_obj.MeshUtility == 'snappyHexMesh': snappy_settings['BoundaryLayers'][self.patch_names[k][mr_id + 1]] = \ { 'NumberLayers': mr_obj.NumberLayers, 'ExpansionRatio': expratio, # 'FinalLayerHeight': self.scale * Units.Quantity(mr_obj.FinalLayerHeight).Value }