openfoam网格信息C=mesh()

Mesh connectivities

Cells

const labelListList& cellPoints = mesh.cellPoints();  // Cell to node
const labelListList& cellEdges = mesh.cellEdges();    // Cell to edge
const cellList& cells = mesh.cells();                 // Cell to face
const labelListList& cellCells = mesh.cellCells();    // Cell to cell

Faces

const faceList& faces = mesh.faces();                   // Face to node
const labelListList& faceEdges = mesh.faceEdges();      // Face to edge
const labelList& faceOwner = mesh.faceOwner();          // Face to owner cell
const labelList& faceNeighbour = mesh.faceNeighbour();  // Face to neighbour cell 

Nodes

const labelListList& pointPoints = mesh.pointPoints();  // Node to node 
const labelListList& pointEdges = mesh.pointEdges();    // Point to edge 
const labelListList& pointFaces = mesh.pointFaces();    // Point to face 
const labelListList& pointCells = mesh.pointCells();    // Point to cell 

Edges

const edgeList& edges = mesh.edges();                   // Edge to node 
const labelListList& edgeFaces = mesh.edgeFaces();      // Edge to face 
const labelListList& edgeCells = mesh.edgeCells();      // Edge to cell

Mesh coordinates

Cell center, face center and node

const volVectorField& C = mesh.C();         // Cell center coordinates
const surfaceVectorField& Cf = mesh.Cf();   // Face center coordinates
const pointField& points = mesh.points();   // Node coordinates

Edge center

Since OpenFOAM is based on the conventional cell-centred Finite Volume Method, edge coordinates are not computed by the fvMesh class. However, if necessary they can be obtained very easily by averaging the 2 node coordinates associated to each edge.

// Include vectorList definition to store edge coordinates
#include "vectorList.H"

// Create edge list which contains edge to node connectivity
const edgeList& edges = mesh.edges();
   
// Create a vectorList to store edge centre coordinates 
// This list has size of edgeList 'edges' and is initialized to zero 
vectorList Ce(edges.size(), vector::zero);             

// Loop over all edges
forAll(edges, edge)
{
   const label& own = edges[edge][0];     // Index of edge owner node
   const label& nei = edges[edge][1];     // Index of edge neighbour node
  
   // Calculate edge center coordinates by averaging node coordinates
   Ce[edge] = 0.5*(points[own] + points[nei]);
}

Boundary mesh data

// Store boundary mesh information
const polyBoundaryMesh& boundaryMesh = mesh.boundaryMesh();

Distinguish between internal and boundary faces

// Loop over all faces (internal and boundary)
forAll(faces, face)
{
  if (mesh.isInternalFace(face)) // Internal face is found
  {
    // Do your calculations for internal faces i.e.
    // U[face] = vector::zero;
  }
  else                           // Boundary face is found
  {
    const label& patch = boundaryMesh.whichPatch(face);       // Boundary patch index
    const label& facei = boundaryMesh[patch].whichFace(face); // Local boundary face index
    
    // Do your calculations for boundary faces i.e.
    // U.boundaryField()[patch][facei] = vector::zero;
  }
}

Boundary patches

// Loop over boundary patches
forAll(mesh.boundary(), patch)
{
  const word& patchName = mesh.boundary()[patch].name();            // Boundary patch name
    
  // Loop over all faces of boundary patch
  forAll(mesh.boundary()[patch], facei)
  {
    const label& bCell = boundaryMesh[patch].faceCells()[facei];    // Boundary cell index
    const label& face = boundaryMesh[patch].start() + facei;        // Face index
        
    // Do your calculations e.g.
    // U.boundaryField()[patch][facei] = vector::zero;
  }
    
  // Loop over all nodes of boundary patch
  forAll(boundaryMesh[patch].meshPoints(), pointi)
  {
    const label& point = boundaryMesh[patch].meshPoints()[pointi];  // Node index
    
    // Do your calculations e.g.
    // U[point] = vector::one;
  }
}

Other useful mesh parameters

// Cell volumes
const scalarField& V = mesh.V();

// Face area normal vectors
const surfaceVectorField& Sf = mesh.Sf();

// Face areas
const surfaceScalarField& magSf = mesh.magSf();

// Face normals
const surfaceVectorField& N = Sf/magSf;

// Total number of cells
const label& nCells = mesh.nCells();

// Total number of nodes
const label& nPoints = mesh.nPoints();

// Total number of internal faces
const label& nInternalFaces = mesh.nInternalFaces();

// Total number of internal nodes
const label& nInternalPoints = mesh.nInternalPoints();

链接:How to get mesh information in OpenFOAM? (jibranhaider.com)https://jibranhaider.com/blog/mesh-information-in-openfoam/#mesh-connectivities

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值