細分化対象としたいパーツは、[select from list]ボタンをクリックすると、[Select Object]の選択リストが有効になるので、このリストの中から選択する。[Dexcs]を選択すると、少し待ち時間があって後、長大なFaceリストが現れる。これはDexcsを構成する全Faceを示しており、これを取得する為時間がかかっているのである。それぞれのFace…の名前の先頭にチェックボックスが表示されており、これの選択如何で、細分化対象をさらに詳細に設定することができるようになっているというのがCfdOF本来の使い方であるが、DEXCSではそういうことはしない。したがって、ここでFaceリストを表示させるのでなく、単に選択パーツを表示させたかったのであるが、その為の工夫が容易ではなさそうであったので、当面はCfdOF本来の選択表示方法を流用していくこととした。
# Add mesh object when CfdAnalysis container is created
FreeCADGui.addModule("CfdMesh")
FreeCADGui.doCommand("analysis.addObject(CfdMesh.makeCfdMesh())")
108: for i in FreeCADGui.ActiveDocument.Document.Objects:
109: if "Shape" in i.PropertiesList:
110: # Do not restrict to solids
111: if not i.Name.startswith("CfdFluidBoundary"):
112: self.solidsNames.append(i.Name)
113: self.solidsLabels.append(i.Label)
となっていた部分を、以下に変更した。
108: for i in FreeCADGui.ActiveDocument.Document.Objects:
109: if i.ViewObject.Visibility:
111: if hasattr(i,"Proxy"):
112: pass
113: else:
114: self.solidsNames.append(i.Name)
115: self.solidsLabels.append(i.Label)
outputStlFile = open(self.stlFileName, 'w')
# refinementRegion として指定(obj.Internal)されたパーツのLabelリストを作成
__region__=[]doc = FreeCAD.activeDocument() for obj in doc.Objects:
if obj.ViewObject.Visibility:
if hasattr(obj, "Proxy") and isinstance(obj.Proxy, _CfdMeshRefinement):
if obj.Internal :
for objList in(obj.LinkedObjects):
__region__.append(objList.Label)
for obj in doc.Objects:
if obj.ViewObject.Visibility:
__objs__=[]
try:
if obj.Shape:
# obj.Labelがregion指定パーツであるかどうか判定
checkRegion = False
for objRegion in __region__:
if obj.Label == objRegion :
print('pass ' + obj.Label)
checkRegion=True
# CfdSolver / Group Object / region指定Obj を除外
if obj.isDerivedFrom("Part::FeaturePython") or obj.isDerivedFrom("App::DocumentObjectGroupPython") or checkRegion:
pass
else:
print('append '+obj.Label)
__objs__.append(obj)
file=self.fileName+obj.Label+'.ast'
Mesh.export(__objs__,file)
importFile = open(file,'r')
temp = importFile.readlines()
for line in temp:
if 'endsolid' in line:
outputStlFile.write('endsolid ' + obj.Label + '\n')
elif 'solid' in line:
outputStlFile.write('solid ' + obj.Label + '\n')
else:
outputStlFile.write(line)
importFile.close
os.remove(file)
except AttributeError:
pass
outputStlFile.close
def initProperties(self, obj):
# Common to all
addObjectProperty(obj, "RelativeLength", 0.75, "App::PropertyFloat", "",
"Set relative length of the elements for this region")
addObjectProperty(obj, 'LinkedObjects', [], "App::PropertyLinkList", "", "Linked objects")
addObjectProperty(obj, "References", [], "App::PropertyPythonObject", "",
"List of mesh refinement objects")
addObjectProperty(obj, "Internal", False, "App::PropertyBool", "",
"Whether the refinement region is a volume rather than surface")
#cfMesh:
addObjectProperty(obj, "RefinementThickness", "0 m", "App::PropertyLength", "cfMesh",
"Set refinement region thickness")
addObjectProperty(obj, "NumberLayers", 0, "App::PropertyInteger", "cfMesh",
"Set number of boundary layers")
addObjectProperty(obj, "ExpansionRatio", 1.2, "App::PropertyFloat", "cfMesh",
"Set expansion ratio within boundary layers")
addObjectProperty(obj, "FirstLayerHeight", "0 m", "App::PropertyLength", "cfMesh",
"Set the maximum first layer height")
# snappy:
addObjectProperty(obj, "RegionEdgeRefinement", 1, "App::PropertyFloat", "snappyHexMesh",
"Relative edge (feature) refinement")
__region__=[]
__rerativeLength__[]
doc = FreeCAD.activeDocument()
for obj in doc.Objects:
if obj.ViewObject.Visibility:
if hasattr(obj, "Proxy") and isinstance(obj.Proxy, _CfdMeshRefinement):
if obj.Internal :
for objList in(obj.LinkedObjects):
__region__.append(objList.Label)
__relativeLength__.append(obj.RelativeLength)
オリジナルのDEXCSランチャーにおいて、細分化領域対象パーツを絞り込んでいた部分
while (self.viewControl.get_gridTableValue(iRow,0)):
for obj in self.doc.Objects:
if obj.Label == self.viewControl.get_gridTableValue(iRow,0):
iRow = iRow + 1
if self.viewControl.get_gridTableValue(iRow-1,1) == MainControl.REGION_STR:
を以下のように変更。
if __region__ :
regionNumber = 0
for objList in __region__ :
for obj in doc.Objects:
if obj.Label == objList :
__patch__ = []
__relativeLength__ = []
__refThickness__ = []
doc = FreeCAD.activeDocument()
for obj in doc.Objects:
if obj.ViewObject.Visibility:
if hasattr(obj, "Proxy") and isinstance(obj.Proxy, _CfdMeshRefinement):
if (not obj.Internal) and (obj.RelativeLength < 1) :
for objList in(obj.LinkedObjects):
__patch__.append(objList.Label)
__relativeLength__.append(obj.RelativeLength)
__refThickness__.append(obj.RefinementThickness)
セルサイズ指定パッチの絞り込み部分
while (self.viewControl.get_gridTableValue(iRow,0)):
iRow = iRow + 1
if (self.viewControl.get_gridTableValue(iRow-1,2) != Model.EMPTY_STR and
self.viewControl.get_gridTableValue(iRow-1,1) != MainControl.REGION_STR):
は、以下変更し、
if __patch__ :
patchNumber = 0
for objList in __patch__ :
for obj in doc.Objects:
if obj.Label == objList :
88: # Add physics object when CfdAnalysis container is created
89: #FreeCADGui.addModule("CfdPhysicsSelection")
90: #FreeCADGui.doCommand("analysis.addObject(CfdPhysicsSelection.makeCfdPhysicsSelection())
91:
92: # Add fluid properties object when CfdAnalysis container is created
93: #FreeCADGui.addModule("CfdFluidMaterial")
94: #FreeCADGui.doCommand("analysis.addObject(CfdFluidMaterial.makeCfdFluidMaterial(’FluidPr
95:
96: # Add initialisation object when CfdAnalysis container is created
97: #FreeCADGui.addModule("CfdInitialiseFlowField")
98: #FreeCADGui.doCommand("analysis.addObject(CfdInitialiseFlowField.makeCfdInitialFlowField
99:
100: # Add solver object when CfdAnalysis container is created
101: FreeCADGui.addModule("CfdSolverFoam")
102: FreeCADGui.doCommand("analysis.addObject(CfdSolverFoam.makeCfdSolverFoam())")
#testDict_maxCellSize = 0.583
for obj in FreeCAD.ActiveDocument.Objects:
if hasattr(obj, "Proxy") and isinstance(obj.Proxy, _CfdMesh):
testDict_maxCellSize = obj.CharacteristicLengthMax
また、メッシュ作成コンテナ中の Base element size: の値そのものは、手入力で変更は可能である。し かし、どうせならモデルを読み込んだ状態にてそのサイズを調べて自動計算した値を表示しておきたい。 CfdMeshTools.py にて、メッシュ作成コンテナが作成される際の def init ブロック中、
# Default to 2 % of bounding box characteristic length
self.clmax = Units.Quantity(self.mesh_obj.CharacteristicLengthMax).Value
if self.clmax <= 0.0:
#shape = self.part_obj.Shape
#cl_bound_mag = math.sqrt(shape.BoundBox.XLength**2 + shape.BoundBox.YLength**2 + shape.Bou
#cl_bound_min = min(min(shape.BoundBox.XLength, shape.BoundBox.YLength), shape.BoundBox.ZLe
#self.clmax = min(0.02*cl_bound_mag, 0.4*cl_bound_min)
xmax = -1.0e+30
xmin = 1.0e+30
ymax = -1.0e+30
ymin = 1.0e+30
zmax = -1.0e+30
zmin = 1.0e+30
doc = FreeCAD.activeDocument()
for obj in doc.Objects:
try:
if obj.Shape:
if obj.Shape.BoundBox.XMax > xmax:
xmax = obj.Shape.BoundBox.XMax
if obj.Shape.BoundBox.XMin < xmin:
xmin = obj.Shape.BoundBox.XMin
if obj.Shape.BoundBox.YMax > ymax:
ymax = obj.Shape.BoundBox.YMax
if obj.Shape.BoundBox.YMin < ymin:
ymin = obj.Shape.BoundBox.YMin
if obj.Shape.BoundBox.ZMax > zmax:
zmax = obj.Shape.BoundBox.ZMax
if obj.Shape.BoundBox.ZMin < zmin:
zmin = obj.Shape.BoundBox.ZMin
except AttributeError:
pass
sumOf3Edges = (xmax-xmin+ymax-ymin+zmax-zmin)
self.mesh_obj.CharacteristicLengthMax = sumOf3Edges / 60.0