Skip to content

Instantly share code, notes, and snippets.

@zhulianhua
Last active September 28, 2015 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhulianhua/0f368465fd419391141e to your computer and use it in GitHub Desktop.
Save zhulianhua/0f368465fd419391141e to your computer and use it in GitHub Desktop.
  • 从Gambit里面画好网格后,周期边界设为wall类型,导出网格,然后运行 FluentMeshToFoam,转换成OpenFOAM 里面内部使用的格式。

  • 更改constant/polyMesh/boundary文件中对应的周期patch,即从wall类型改为cyclic, 如下:

          right
          {
             type            cyclic;
             inGroups        1(cyclic);
             nFaces          20;
             startFace       5572;
             // matchTolerance  1;
             transform       unknown;
             neighbourPatch  left;
            }
            left
           {
              type            cyclic;
              inGroups        1(cyclic);
              nFaces          20;
              startFace       5592;
              //matchTolerance  1;  
              transform       unknown;
              neighbourPatch  right;
            }
    
  • 运行 checkMesh检查网格,这时极有可能出现如下错误:

      --> FOAM FATAL ERROR:
      face 11 area does not match neighbour by 7.69230764917381% -- possible face ordering problem.
      patch:right my area:3.23950377747049e-14 neighbour area:2.999540535990633e-14 matching tolerance:0.0001
      Mesh face:5583 fc:(9.999999999999999e-06 5.2884700335e-06 0)
      Neighbour fc:(0 5.422218442549999e-06 0)
      If you are certain your matching is correct you can increase the 'matchTolerance' setting in the patch dictionary in the boundary file.
      Rerun with cyclic debug flag set for more information.
      
          From function cyclicPolyPatch::calcTransforms()
          in file meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C at line 221.
      
      FOAM exiting
    
  • 这是由于两个周期patch的boundary faces的顺序不一致导致的。解决这个问题需要使用createPatch工具。具体做法是首先在constant/polyMesh/boundary的周期patch中加入 matchTolerance 1;字段,就是先骗过网格检查; 然后创建如下system/createPatchDict文件;之后运行createPatch -overwrite; 最后把constant/polyMesh/boundary中的 matchTolerance 1;字段注释掉,并checkMesh再次检查网格。

      FoamFile
      {
          version     2.0;
          format      ascii;
          class       dictionary;
          object      createPatchDict;
                }
      
      // This application/dictionary controls:
      // - optional: create new patches from boundary faces (either given as
      //   a set of patches or as a faceSet)
      // - always: order faces on coupled patches such that they are opposite. This
      //   is done for all coupled faces, not just for any patches created.
      // - optional: synchronise points on coupled patches.
      
      // 1. Create cyclic:
      // - specify where the faces should come from
      // - specify the type of cyclic. If a rotational specify the rotationAxis
      //   and centre to make matching easier
      // - always create both halves in one invocation with correct 'neighbourPatch'
      //   setting.
      // - optionally pointSync true to guarantee points to line up.
      
      // 2. Correct incorrect cyclic:
      // This will usually fail upon loading:
      //  "face 0 area does not match neighbour 2 by 0.0100005%"
      //  " -- possible face ordering problem."
      // - in polyMesh/boundary file:
      //      - loosen matchTolerance of all cyclics to get case to load
      //      - or change patch type from 'cyclic' to 'patch'
      //        and regenerate cyclic as above
      
      // Do a synchronisation of coupled points after creation of any patches.
      // Note: this does not work with points that are on multiple coupled patches
      //       with transformations (i.e. cyclics).
      pointSync false;
      
      // Patches to create.
                patches
      (
          {
              // Name of new patch
              name right;
      
              // Dictionary to construct new patch from
              patchInfo
              {
                  type cyclic;
                  neighbourPatch left;
      
                  // Optional: explicitly set transformation tensor.
                  // Used when matching and synchronising points.
                  // transform rotational;
                  // rotationAxis    ( 0 0 1 );
                  // rotationCentre  ( 0.3 0 0 );
              }
      
              // How to construct: either from 'patches' or 'set'
              constructFrom patches;
      
              // If constructFrom = patches : names of patches. Wildcards allowed.
              patches (right);
      
              // If constructFrom = set : name of faceSet
              // set f0;
          }
      );
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment