⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sift5.c

📁 三维矢量有限元-矩量法电磁场分析程序。 EMAP5 is a full-wave electromagnetic field solver that combines the method of m
💻 C
📖 第 1 页 / 共 5 页
字号:
 	                MetalEdgeStat[HexEdgeNum[EdgeNum][5]-1]++;
 	                MetalEdgeStat[HexEdgeNum[EdgeNum][8]-1] =2;
 	                MetalEdgeStat[HexEdgeNum[EdgeNum][10]-1]++;
 	                MetalEdgeStat[HexEdgeNum[EdgeNum][14]-1]++;
                    }
                }
 
        }

        if( LeftWall )
        {
            i=XmaxWall-1;
            for(k=0;k<ZdiM;k++)
                for(j=0;j<YdiM;j++)
                {
                    EdgeNum = k*YdiM*XdiM + j*XdiM + i;
                    if( (j>=YminWall) && (j<YmaxWall) &&  
                        (k>=ZminWall) && (k<ZmaxWall) )
                    {
                        MetalEdgeStat[HexEdgeNum[EdgeNum][3]-1] ++;
                        MetalEdgeStat[HexEdgeNum[EdgeNum][7]-1] ++; 
                        /* diagonal edge */
                        MetalEdgeStat[HexEdgeNum[EdgeNum][9]-1] =2; 
                        MetalEdgeStat[HexEdgeNum[EdgeNum][12]-1]++;
                        MetalEdgeStat[HexEdgeNum[EdgeNum][16]-1]++;
                    }  /* if( (j>=YminWall */
                }    /* for */
  
        } /* if(LeftWall) */

    } /* for( PatchNum */

  
}   /* end of   DetectBoundEdgeStatus()  */




/***************************************************************************
Prototype:  void  Tetra_Edge_Div1() 
Description:  To divide one hexahedron into five tetrahedra. There are two  
              methods to do that. This subroutine uses one method.   
              Tetra_Edge_Div2() use the other one. 
Input value:   none 
Return value:   none 
Global value used:   HexNum, TetNode, HexNode, TetEdge, HexEdgeNum.
Global value modified:    none 
Subroutines called:     none 
***************************************************************************/
void TetraEdgeDiv1()
{
    int Count, i, j;

    /* map a hexhedron into five tetrahedron */
    int TetraNode[][4]={ {0, 3, 2, 6}, {3, 5, 7, 6}, {0, 1, 3, 5},
                         {0, 6, 4, 5}, {0, 5, 3, 6} };

    /* generate the tetrahedron edge table from the hexhedron table */

    /* the sign of the tetrahedron edges */
    int TetraEdgeSign[][6]={ {1, 1, 1, -1, -1, 1}, {1, 1, 1,  1, -1, -1},
                             {1, 1, 1,  1, -1, 1}, {1, 1, 1, -1,  1,  1},
                             {1, 1, 1, -1, -1, 1} };

    /* the map table among tetrahedra and the hexhedron */
    int TetraEdge[][6]={ {2, 1, 8, 4, 11, 10}, {9, 12, 11, 16, 15, 17},
                         {0, 2, 6, 3, 7,  9},  {8, 5, 6, 14, 15, 13},
                         {6, 2, 8, 9, 15, 11}  };


    Count = 5*HexNum;  /* one hexhedron is divided into five tetrahedra */

    
    for(i=0; i<5; i++) 
    {  
        /* the ith tetrahedron */

        for(j=0; j<4; j++) /* counter of the node number of one tetrahedron */
            TetNode[Count+i][j]=HexNode[HexNum][ TetraNode[i][j] ];

        for(j=0; j<6; j++) /* counter of the edge number of one tetrahedron */
            TetEdge[Count+i][j] = TetraEdgeSign[i][j]*
                HexEdgeNum[HexNum][ TetraEdge[i][j] ];

    }  /* for(i=0 */

}



/****************************************************************************
Prototype:    void    Global_Edge_Ends_Div1() 
Description:  To assign start and end nodes for the 18 edges associated with one
              hexahedron. This subroutine is used accompanying with  
              Tetra-Edge_Div1(). 
Input value:     none 
Return value:     none 
Global value used:     GlobalEdgeEnds, HexNode, HexNum, 
Global value modified:     none 
Subroutines called:     none 
****************************************************************************/
void GlobalEdgeEndsDiv1()
{
    int i;  /* counter */
    
    int StartNode[]={0, 0, 0, 1, 2, 0, 0, 1, 0, 3, 2, 3, 3, 4, 4, 5, 5, 6 },
        EndNode[]=  {1, 2, 3, 3, 3, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 7 };
 
    for(i=0; i<18; i++) 
    {
        int EdgeNum = HexEdgeNum[HexNum][i];  /* the edge number */
        /* find out the start node */
        GlobalEdgeEnds[EdgeNum-1][0]=HexNode[HexNum][ StartNode[i] ];
        /* findout the end node */
        GlobalEdgeEnds[EdgeNum-1][1]=HexNode[HexNum][ EndNode[i] ];
    }
}




/****************************************************************************
Prototype:  void  Tetra_Edge_Div2() 
Description:  To divide one hexahedron into five tetrahedron. There are two  
              methods to do that. Tetra_Edge_Div1() uses 
              one method, Tetra_Edge_Div2() uses the other method. 
Input value:  none 
Return value:  none 
Global value used:   HexNum, TetNode, HexNode, TetEdge, HexEdgeNum, 
Global value modified:   none 
Subroutines called:  none *****************************************************************************/
void TetraEdgeDiv2()
{
    int Count;

    /* map a hexhedron into five tetrahedron */
    int TetraNode[][4]={ {0, 1, 2, 4}, {1, 7, 4, 5}, {1, 7, 3, 2},
                         {2, 6, 4, 7}, {1, 2, 4, 7} };

    /* generate the tetrahedron edge table from the hexhedron table */

    /* the sign of the tetrahedron edges */
    int TetraEdgeSign[][6]={ {1, 1, 1, 1, -1, 1}, {1, 1, 1,  -1, 1, 1},
                             {1, 1, 1,  -1, 1, -1}, {1, 1, 1, -1,  -1,  1},
                             {1, 1, 1, 1, -1, 1} };

    /* the map table among tetrahedra and the hexhedron */
    int TetraEdge[][6]={ {0, 1, 5, 2, 6, 8}, { 9, 6, 7, 15, 16, 13},
                         {9, 3, 2, 12, 11, 4}, {10, 8, 11, 14, 17, 15}, 
                         {2, 6, 9, 8, 11, 15}  };

    Count = 5*HexNum;

    for(i=0; i<5; i++) 
    {  
        /* the ith tetrahedron */

        for(j=0; j<4; j++) /* counter of the node number of one tetrahedron */
            TetNode[Count+i][j]=HexNode[HexNum][ TetraNode[i][j] ];

        for(j=0; j<6; j++) /* counter of the edge number of one tetrahedron */
            TetEdge[Count+i][j] = TetraEdgeSign[i][j]*
                HexEdgeNum[HexNum][ TetraEdge[i][j] ];

    }  /* for(i=0 */


}   /* end of TetraEdgeDiv2()  */



/***************************************************************************
Prototype:    void    Global_Edge_Ends_Div2() 
Description:  To assign start and end nodes for the 18 edges associated 
              with one hexahedron. This subroutine is 
              used accompanying with Tetra-Edge_Div2(). 
Input value:     none 
Return value:     none 
Global value used:     GlobalEdgeEnds, HexNode, HexNum, 
Global value modified:     none 
Subroutines called:     none
***************************************************************************/
void GlobalEdgeEndsDiv2()
{

    int i;  /* counter */
    
    int StartNode[]={0, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 3, 4, 4, 4, 5, 6 },
        EndNode[]=  {1, 2, 2, 3, 3, 4, 4, 5, 4, 7, 6, 7, 7, 5, 6, 7, 7, 7 };
 
    for(i=0; i<18; i++) 
    {
        int EdgeNum = HexEdgeNum[HexNum][i];  /* the edge number */
        /* find out the start node */
        GlobalEdgeEnds[EdgeNum-1][0]=HexNode[HexNum][ StartNode[i] ];
        /* findout the end node */
        GlobalEdgeEnds[EdgeNum-1][1]=HexNode[HexNum][ EndNode[i] ];
    }  /* for(i=0 */

}  /* end of GlobalEdgeEndDiv2() */





/**************************************************************************
Prototype:    void    FindTetraHedronFaceNodes(int TetHedronNum) 
Description:   To find tetrahedron faces that lie on the surface of FEM   
               region. 
Input value:     
    int TetHedronNum--- index of the tetrahedron 
Return value:     none 
Global value used:     EdgeStat,TetNode, NodeCord 
Global value modified:     none 
Subroutines called:     none
***************************************************************************/
void FindTetraHedronFaceNodes( int TetHedronNum)
{
    int Count_i,Count_j,NCount_j,NCount_k,NCount_l;
    int Duplicate=0,ECount_j,ECount_k,ECount_l;
    int TrngleEdge0,TrngleEdge1,TrngleEdge2;
    int TrngleNode0,TrngleNode1,TrngleNode2;
    int TrngleNodeX,TrngleNodeY,TrngleNodeZ;

    for(Count_i=0;Count_i<=3;Count_i++)
    {
       
        if( Count_i==0 ) 
        {
            ECount_j=0; 
            ECount_k=1; 
            ECount_l=3;    
            NCount_j=2; 
            NCount_k=1; 
            NCount_l=0;

        }
        else if(Count_i==1) 
        {   
            ECount_j=0;
            ECount_k=4; 
            ECount_l=2; 
            NCount_j=3; 
            NCount_k=0; 
            NCount_l=1;

        }
        else if(Count_i==2) 
        {
            ECount_j=3; 
            ECount_k=5;
            ECount_l=4; 
            NCount_j=3; 
            NCount_k=1; 
            NCount_l=2;

        }
        else                
        {
            ECount_j=1; 
            ECount_k=2; 
            ECount_l=5;
            NCount_j=3; 
            NCount_k=2; 
            NCount_l=0;
        }
      
        TrngleEdge0 = EdgeStat[abs(TetEdge[TetHedronNum][ECount_j])-1];
        TrngleEdge1 = EdgeStat[abs(TetEdge[TetHedronNum][ECount_k])-1];
        TrngleEdge2 = EdgeStat[abs(TetEdge[TetHedronNum][ECount_l])-1];

        TrngleNode0 = TetNode[TetHedronNum][NCount_j]-1;
        TrngleNode1 = TetNode[TetHedronNum][NCount_k]-1;
        TrngleNode2 = TetNode[TetHedronNum][NCount_l]-1;

        if((((fabs((double)NodeCord[TrngleNode0][0]-NodeCord[TrngleNode1][0])<1e-5)&&
             (fabs((double)NodeCord[TrngleNode0][0]-NodeCord[TrngleNode2][0])<1e-5))
         ||((fabs((double)NodeCord[TrngleNode0][1]-NodeCord[TrngleNode1][1])<1e-5) &&
            (fabs((double)NodeCord[TrngleNode0][1]-NodeCord[TrngleNode2][1])<1e-5) )
         ||((fabs((double)NodeCord[TrngleNode0][2]-NodeCord[TrngleNode1][2])<1e-5) &&
            (fabs((double)NodeCord[TrngleNode0][2]-NodeCord[TrngleNode2][2])<1e-5) )
          )
          && ((TrngleEdge0==-1) && (TrngleEdge1==-1) && (TrngleEdge2==-1))
        )
        {
            Duplicate = 0;

            for(Count_j=0;Count_j<=TotTetFaceNum;Count_j++)
            {
                TrngleNodeX = TrngleNode[Count_j][0]-1;
                TrngleNodeY = TrngleNode[Count_j][1]-1;
                TrngleNodeZ = TrngleNode[Count_j][2]-1;
                if( ( (TrngleNode0==TrngleNodeX) && 
                    (((TrngleNode1==TrngleNodeY) && 
                      (TrngleNode2==TrngleNodeZ)) 
                   || ((TrngleNode1==TrngleNodeZ) &&  
                      (TrngleNode2==TrngleNodeY)))) 
                   || ((TrngleNode1==TrngleNodeY) && 
                     (((TrngleNode0==TrngleNodeX) && 
                       (TrngleNode2==TrngleNodeZ)) 
                   || ((TrngleNode0==TrngleNodeZ) && 
                       (TrngleNode2==TrngleNodeX))))
                   ||( (TrngleNode2==TrngleNodeZ) && 
                     (((TrngleNode0==TrngleNodeX) && 
                       (TrngleNode1==TrngleNodeY)) 
                   || ((TrngleNode0==TrngleNodeY) && 
                       (TrngleNode1==TrngleNodeX)))
                    )
                  )
                {
                     Duplicate = Count_j + 1; 
                     break;
                }   /* if ()  */

                else 
                {   
                    Duplicate = 0; 
                    continue;
                }  /* else */
            }      /* for() */ 

            if( Duplicate==0 )
            {
                int i=TotTetFaceNum, j=TotTetFaceNum, k=TetHedronNum;
 
                TrngleNode[i][0]=TetNode[k][NCount_j];
                TrngleNode[i][1]=TetNode[k][NCount_k];
                TrngleNode[i][2]=TetNode[k][NCount_l];
                TrngleEdge[j][0]=TetEdge[k][ECount_j];
                TrngleEdge[j][1]=TetEdge[k][ECount_k];
                TrngleEdge[j][2]=TetEdge[k][ECount_l];
                TetBoundFaceTetHedronNum[j]=k+1;
                TetBoundFaceFaceNum[j]=Count_i+1;
                TotTetFaceNum++;

            }   /* if( Duplicate==0 ) */
        }       /* if( ) */      
    }           /* for(Count */

}               /* end of FindTetrahedronFaceNodes() */    





/*****************************************************************************
Prototype:    void    ModifyBoundFaces(int TrngleFace) 
Description:    To orient the edges of each tetrahedron face to consistent 
                with   the reference direction 
Input value: 
    int TrngleNum--- the index of the boundary face 
Return value: none 
Global value used:     TrngleNode, GlobalEdgeEnds, 
Global value modified:     none 
Subroutines called:     none 
******************************************************************************/
void ModifyBoundFaces(int TrngleFace)
{
    int i,Node1,Node2,Node3,Node4,Edge1;

    for(i=0;i<=2;i++)
    {
        Node1= TrngleNode[TrngleFace][i];
        Node2= TrngleNode[TrngleFace][(i+1)%3];
        Edge1= abs(TrngleEdge[TrngleFace][(i+2)%3]);
        Node3= GlobalEdgeEnds[Edge1-1][0];
        Node4= GlobalEdgeEnds[Edge1-1][1];

        if( (Node1==Node3) && (Node2==Node4) )
            TrngleEdge[TrngleFace][(i+2)%3] = Edge1;
        else TrngleEdge[TrngleFace][(i+2)%3] = -Edge1;

    }  /* for(i=0 */
}      /* end if ModifyBoundFaces()  */
 
 


/***************************************************************************
Prototype:    void    ComputeTrngleCentroid(int, double **, int **, double **) 
Description:    To compute the centroid of a triangular patch 
Input value: 
    int TrngleNum  --- the triangle number 
    double **Cord,  --- the global node table 
    int **BFaceNode --- the node of the triangle 
    double **CenTroid --- where the results are stored. 
Return value: none 
Global value used: none 
Global value modified: none 
Subroutines called: VTXadd2() 
*****************************************************************************/
void ComputeTrngleCentroid(int TrngleNum,double **Cord, int **BFaceNode,
                           double **CenTroid)
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -