DEXCSランチャーv2.5製作メモ / 4.3

4.3 メッシュ細分化タスク画面の改変その2

図38.追加したメッシュ細分化パラメタ



パーツを対象として設定可能なパラメタとして、これまで組み込みが出来ていなかったパラメタを新たに3つ設定できるようにした(図38.における赤枠部分)。すなわち、

  1. keepCellsIntersectingPatches
  2. removeCellsIntersectingPatches
  3. allowDiscontinuity

であり、いずれも使用するかどうかをチェックボックスで設定すれば良いので、GUIの実装やプロパティ化はこれまでのやり方を流用でき、簡単であった。

(1) GUIコンポーネントの追加(dexcsTaskPanelCfdMeshrefinement.ui)

  • keepCellsIntersectingPatches
      <!-- checkBox (keepCellsIntersectingPatches) -->
      <item row="11" column="0" colspan="2">
       <widget class="QCheckBox" name="check_keepCells">
        <property name="text">
         <string>keepCellsIntersectingPatches</string>
        </property>
       </widget>
      </item>
  • removeCellsIntersectingPatches
      <!-- checkBox (removeCellsIntersectingPatches) -->
      <item row="12" column="0" colspan="2">
       <widget class="QCheckBox" name="check_removeCells">
        <property name="text">
         <string>removeCellsIntersectingPatches</string>
        </property>
       </widget>
      </item>
  • allowDiscontinuity
            <!-- checkBox (allowDiscontinuity) -->
            <item row="3" column="0" colspan="2">
            <widget class="QCheckBox" name="check_allowdiscont">
                <property name="text">
                <string>allowDiscontinuity</string>
                </property>
            </widget>
            </item>

(2) プロパティの追加(CfdMeshRfinement.py)

def initProperties(…)に以下追加。

        addObjectProperty(obj, "KeepCell", False, "App::PropertyBool", "",
                          "Keep cells in the mesh template which intersect selected objects)"
        addObjectProperty(obj, "RemoveCell", False, "App::PropertyBool", "",
                          "Remove cells the cells intersecte by the selected objects")
        addObjectProperty(obj, "AllowDiscont", True, "App::PropertyBool", "",
                          "Allow discontinuity of boundary layers")

これにより、プロパティリストが以下のように赤枠部が追加表示される。

図39.追加したプロパティ

(3) メッシュ作成タスク画面とプロパティの関連付け(_dexcsTaskPanelCfdMeshRefinement.py)

def accept(sel)にて、メッシュタスク画面の状態をプロパティリストに反映

        FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.KeepCell "
                             "= {}".format(self.obj.Name, self.form.check_keepCells.isChecked()))
        FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.RemoveCell "
                             "= {}".format(self.obj.Name, self.form.check_removeCells.isChecked()))
        FreeCADGui.doCommand("FreeCAD.ActiveDocument.{}.AllowDiscont "
                             "= {}".format(self.obj.Name, self.form.check_allowdiscont.isChecked()))

def load(self) にて、プロパティリストの値をメッシュタスク画面に反映

        self.form.check_keepCells.setChecked(self.obj.KeepCell)
        self.form.check_removeCells.setChecked(self.obj.RemoveCell)
        self.form.check_allowdiscont.setChecked(self.obj.AllowDiscont)

(4) meshDict作成(dexcsCfdNeshTools.py)

  • allowDiscontinuity

3-6-(3) で実施した改変に、以下の朱字部分を追加。

        __patch__ = []
        __nLayer__ = []
        __expRatio__ = []
        __firstLayerHeight__ = []
        __allowDiscont__ = []
        __keepCells__ = []
        __removeCells__ = []
        doc = FreeCAD.activeDocument()
        for obj in doc.Objects:
            if obj.ViewObject.Visibility:
                if hasattr(obj, "Proxy") and isinstance(obj.Proxy, _CfdMeshRefinement):
                    if obj.NumberLayers > 1 :                    
                        for objList in(obj.LinkedObjects):
                            __patch__.append(objList.Label) 
                            __nLayer__.append(obj.NumberLayers) 
                            __expRatio__.append(obj.ExpansionRatio) 
                            __firstLayerHeight__.append(obj.FirstLayerHeight) 
                            if obj.AllowDiscont == 1:
                                __allowDiscont__.append('1')
                            else: 
                                __allowDiscont__.append('0') 
                    if obj.KeepCell == 1:
                        for objList in(obj.LinkedObjects):
                            __keepCells__.append(objList.Label)
                    if obj.RemoveCell == 1:
                        for objList in(obj.LinkedObjects):
                            __removeCells__.append(objList.Label)

紫色部分は、この後の keepCellsIntersectingPatches、にて使用する。

FirstLayerHeight = str(__firstLayerHeight__[patchNumber]).replace('m','') 
FirstLayerHeight = str(float(FirstLayerHeight)*self.mesh_obj.ScaleToMeter)

strings3 = [         
'\t\t'                 + objList + '\n',
'\t\t{\n',
'\t\t\t// number of layers (optional)\n',
'\t\t\tnLayers    '    + str(__nLayer__[patchNumber]) + ';\n',
'\t\t\n',
'\t\t\t// thickness ratio (optional)\n',
'\t\t\tthicknessRatio ' + str(__expRatio__[patchNumber]) + ';\n',
'\t\t\n',
'\t\t\t// max thickness of the first layer (optional)\n',
'\t\t\tmaxFirstLayerThickness ' + FirstLayerHeight + '; // [m]\n',
'\t\t\n',
'\t\t\t// active 1 or inactive 0\n',
'\t\t\tallowDiscontinuity ' + __allowDiscont__[patchNumber] + ';\n',
'\t\t}\n'

なお、青字部分は、3-6-(3) 以降、スケール変更機能を追加したことを踏まえて、それに対応した処置である。

  • keepCellsIntersectingPatches
  • removeCellsIntersectingPatches

どちらもほとんど同じやり方で出来た。基本は、string4[]を定義するブロックにおいて、

        'keepCellsIntersectingPatches\n',
        '{\n',
        #'// patchName\n',
        #'//\t{\n',
        #'//\t\tkeepCells 1; // 1 active or 0 inactive\n',
        #'//\t}\n',
        keepCellsListString,
        '}\n',
        '\n',
        '// remove cells where distinct parts of the mesh are joined together (optional)\n',
        '// active only when keepCellsIntersectingBoundary is active\n',
        '// checkForGluedMesh    0; // 1 active or 0 inactive\n',
        '\n',
        '// remove cells the cells intersected\n',
        '// by the selected patched/subsets\n',
        '// from the mesh template (optional)\n',
        '// it is active when keepCellsIntersectingBoundary\n',
        '// is switched on\n',
        'removeCellsIntersectingPatches\n',
        '{\n',
        #'// patchName\n',
        #'//\t{\n',
        #'//\t\tkeepCells 1; // 0 remove or 1 keep\n',
        #'//\t}\n',
        removeCellsListString,
        '}\n',

緑色部のコメント行として出力していた部分をコメントアウト(削除でもOK)し、予め下記に作成しておいたkeepCellsListStringremoveCellsListString に置き換えるようにした。

keepCellsListString = ""
if __keepCells__ :
    for objList in __keepCells__:
        keepCellsListString = keepCellsListString + "\t" + objList + "\n\t{\n\t\tkeepCells 1; //1 active or 0 inactive \n\t}\n"
else:
    keepCellsListString = keepCellsListString + "//\t" + "patchName" + "\n//\t{\n//\t\tkeepCells 1; //1 active or 0 inactive \n//\t}\n"

removeCellsListString = ""
if __removeCells__ :
    for objList in __removeCells__:
        removeCellsListString = removeCellsListString + "\t" + objList + "\n\t{\n\t\tkeepCells 0; //0 remove or 1 keep \n\t}\n"
else:
    removeCellsListString = removeCellsListString + "//\t" + "patchName" + "\n//\t{\n//\t\tkeepCells 1; //0 remove or 1 keep \n//\t}\n"

また、__keepCells__、__removeCells__のパッチ名リストは、少し上に記した紫色部分で取得してある。

前へ 目次 次へ

Share

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください