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
89: def get_solver_cmd(self, case_dir):
90: self.initResiduals()
91:
92: self.residualPlot = ResidualPlot()
93:
94: # Environment is sourced in run script, so no need to include in run command
95: cmd = CfdTools.makeRunCommand(’./Allrun’, case_dir, source_env=False)
96: FreeCAD.Console.PrintMessage("Solver run command: " + ’ ’.join(cmd) + "\n")
97: return cmd
logFile を読み込んで、その内容を process output(loglines, niter) に渡して、 residualPlot.updateResiduals (プロット図をアップデート)しようとするもので、 CfdRunnableFoam.py 中のそれを真似して作成したもの である。 process output(loglines, niter) も、 CfdOF モジュールとの連携を考えていないので、
66: def process_output(text, niter):
67: itimer = 0
68: for line in text:
69: #print(line),
70: split = line.split()
71:
72: # Only store the first residual per timestep
73: if line.startswith(u"Time = "):
74: niter += 1
75:
76: # print split
77: if "Ux," in split and niter-1 > len(UxResiduals):
78: UxResiduals.append(float(split[7].split(’,’)[0]))
79: if "Uy," in split and niter-1 > len(UyResiduals):
80: ... 以下省略 ...