Functions in emap5.c


Table of Contents
  1. ComputeBddMatrix()
  2. ComputeCMatrix()
  3. ComputeCorrectionTerm()
  4. ComputeDMatrix()
  5. ComputeGaussQuadPoint()
  6. ComputeNonSingul()
  7. ComputeNonSingul1()
  8. ComputeParameters()
  9. ComputeSingul()
  10. ComputeSourceVector()
  11. ComputeTetraHedronVolume()
  12. ComputeTrngleCentroid
  13. ConjugateSolver()
  14. CreateRHSVector()
  15. FEMMatrixCompute()
  16. InnerProduct()
  17. InvertMatrix()
  18. MatrixVectorProduct()
  19. PrintOuput()
  20. ReadInputFile()
  21. SearchNonZeroElement()
  22. SurfaceFieldCompute()
  23. TetFaceAreaNormal()
  24. VectorNorm()


ComputeBddMatrix()

Prototype:   void ComputeBddMatrix(int ObservTrngle, int SourceTrngle,
                                double *ObsTrngleEdgeLen, double *SrcTrngleEdgeLen,
                                int *ObservTrngleNode, int *SourceTrngleNode,
                                int *ObservTrngleEdge, int *SourceTrngleEdge,
                               double *SrcTrngleNorm, double BE[][3] )
Description:    Compute the B matrix generated by FEM. Only Bdd has non-zero
                elements, thus only store Bdd.
Input value:
    int ObservTrngle, SourceTrngle --- the source and observing triangle
                                       indices to the trianle table
    double *ObsTrngleEdgeLen  --- the observing triangle's edge length
    double *SrcTrngleEdgeLen  --- the source triangle's edge length
    int *ObservTrngleNode  --- the observing triangle's nodes
    int *SourceTrngleNode  --- the source triangle's nodes
    int *ObservTrngleEdge  --- the observing triangle's edges
    int *SourceTrngleEdge  --- the source triangle's edges
    double *SrcTrngleNorm   --- the normal vector of the source triangle.
    double BE[][3]  --- to store the results of BE for this triangle pair.
Return value:     none
Global value used:  NodeCord, Junction, Bdd,
                    GlobalEdgeEnds, TrngleCenTroid,
Global value modified:      none
Subroutines called:    sign(),  TrngleArea(), VTXdot()
(Click to go back to Table of Contents.)

ComputeCMatrix()

Prototype:  void ComputeCMatrix(int ObservTrngle, int SourceTrngle,
                    double *ObsTrngleEdgeLen, double *SrcTrngleEdgeLen,
                    int *ObservTrngleNode, int *SourceTrngleNode,
                    int *ObservTrngleEdge, int *SourceTrngleEdge,
                    double **ObsPointArray)
Description:   Fill the Moment Method matrix C, partition it to
               Ccc, Ccd, Cdd and  Cdc.
Input value:
    int ObservTrngle, SourceTrngle --- the source and observing triangle
                                       indices to the trianle table
    double *ObsTrngleEdgeLen  --- the observing triangle's edge length
    double *SrcTrngleEdgeLen  --- the source triangle's edge length
    int *ObservTrngleNode  --- the observing triangle's nodes
    int *SourceTrngleNode  --- the source triangle's nodes
    int *ObservTrngleEdge  --- the observing triangle's edges
    int *SourceTrngleEdge  --- the source triangle's edges
    double **ObsPointArray --- the observing triangle's Gaussian Quadrature
                               point array
Return value:  none
Global value used:     TrngleNode,TrngleNormal,TotQuadPoint,
                       TrngleCenTroid, NodeCord, Ccc, Ccd,  Cdd, Cdc.
Global value modified:     none
Subroutines called:     ComputeGaussQuadPoint(),ComputeSingul(),
                        COMplex_Cmplx(), ComputeNonSingul(), COMplex_Add2(),
                        COMplex_Sub(), COMplex_Null()

(Click to go back to Table of Contents.)



ComputeCorrectionTerm()

Prototype:    void    ComputeCorrectionTerm()
Description:     To couple the MoM matrix equation to the FEM matrix equation. The main idea is to obtain Jd  from C and D. Then couple to the FEM matrix.
Input value:     none
Return value:     none
Global value used:     Ccc, Ccd, Cdc, Cdd, Bdd, TotExtMetalEdgeNum, HybrdBoundEdgeNum, Gd
Global value modified:    InvertMatrix(), COMplex_Add()
Subroutines called:     none.

(Click to go back to Table of Contents.)



ComputeDMatrix()

Prototype: void ComputeDMatrix(int  ObservTrngle, int SourceTrngle,
                    double *ObsTrngleEdgeLen, double *SrcTrngleEdgeLen,
                    int *ObservTrngleNode, int *SourceTrngleNode,
                    int *ObservTrngleEdge, int *SourceTrngleEdge,
                    double **ObsPointArray, double BE[][3])
Description:    Fill D matrix generated by MOM. Partition it to Dcd and Ddd.
Input value:
    int ObservTrngle, SourceTrngle --- the source and observing triangle
                                       indices to the trianle table
    double *ObsTrngleEdgeLen  --- the observing triangle's edge length
    double *SrcTrngleEdgeLen  --- the source triangle's edge length
    int *ObservTrngleNode  --- the observing triangle's nodes
    int *SourceTrngleNode  --- the source triangle's nodes
    int *ObservTrngleEdge  --- the observing triangle's edges
    int *SourceTrngleEdge  --- the source triangle's edges
    double **ObsPointArray --- the observing triangle's Gaussian Quadrature
                               point array
    double BE[][3]  --- store the results of BE for this triangle pair.
Return value:   none
Global value used:   Junction,  NordCord, Ddd, Dcd,
Global value modified:     none
Subroutines called:   sign(),  Real_Mul(), computeNonSingul1(),
                      COMplex_Add2(), COMplex_Null(),
                      ComputeGaussQuadPoint().
 
(Click to go back to Table of Contents.)

ComputeGaussQuadPoint()

Prototype:    void    ComputeGaussQuadPoint(int QuadPoint, int *TrngleNode, double *SrcPointCol)
Description: To compute the coordinates of 7-point Gauss nodes of a triangular patch.
Input value: Return value: none
Global value used: NodeCord, Qpnt
Global value modified:    none
Subroutines called:    none
Note: Not very sure.
(Click to go back to Table of Contents.)
 


ComputeNonSingul()

Prototype:    void    ComputeNonSingul(int *TrngleNode, double One, double *MidPoint)
Description: To evaluate the MOM surface integral numerically when the observation triangle and the source triangle are different.
Input value: Return value: none
Global value used: none
Global value modified: none
Subroutines called: COMplex_add(), COMplex_Cmplx(), COMplex_Expon(), Real_Mul(), COMplex_Sub()

(Click to go back to Table of Contents.)


ComputeNonSingul1()

Prototype: void ComputeNonSingul(int *TrngleNode, double One,
                                 double *MidPoint, complex *Ino_PQ,
                                 complex *Ixi_PQ,
                                 complex *Ieta_PQ, complex *Izeta_PQ)
Description: To evaluate the MOM surface integral numerically when the
             observation triangle and the source triangle are different.
Input value:
    int *TrngleNode --- nodes of the source triangle
    double One  --- a factor
    double *MidPoint --- middle point of the observing trianlge
Return value:
    complex *Ino_PQ   --- to store the value of Ino
    complex *Ixi_PQ   --- to store the value of Ixi
    complex *Ieta_PQ  --- to store the value of Ieta
    complex *Izeta_PQ --- to store the value of Izeta.
    The above values are used in ComputeCMatrix().
Global value used: none
Global value modified: none
Subroutines called: COMplex_add(), COMplex_Cmplx(), COMplex_Expon(),
                    Real_Mul(), COMplex_Sub()
 

(Click to go back to Table of Contents.)


ComputeParameters()

Prototype:    void    ComputeParameters()
Description:    To computes parameters(TetVolume, TrngleArea, TrngleCentroid and etc) which are necessary to build the FEM matrix and MOM matrix,
Input value:    none
Return value:    none
Global value used:     AbsPermeable, AbsPermitt, CFactor1, CFactor2, Cfactor3, EdgeLength, FreeSpaceVel, ImpeDance, NodeCord, OperateFreq, GlobalEdgeEnds, TetLocalEdge, TetLocalNodeNum, TetVolume, TotEdgeNum, TotTetElement, TotTrnlgeNum,TParam, TrngleArea, TrngleCentroid, WaveLength, WaveNumber,
Global value modified:     CFactor1, CFactor2, Cfactor3, FreeSpaceVel, TetVolume, TrngleArea, TrngleCentroid,
Subroutines called:     COMplex_Cmplx(), ComputeTetraHeronVolume(), ComputeTrngleCentroid(), Real_Mul() TetfaceAreaNormal(), VTXmag()

(Click to go back to Table of Contents.)


ComputeSingul()

Prototype:    void    ComputeSingul(int *Node, double *MidPoint, double AREA)
Description:     To evaluate the singularity of the MOM integral analytically when the observing triangle coincides with the source triangle. The results are stored in global variables RealIno, RealIxi and RealIeta.
Input value: Return value: none
Global value used: double **NodeCord
Global value modified: RealIno, RealIxi, RealIeta
Subroutines called: none

(Click to go back to Table of Contents.)
 


ComputeSourceVector()

Prototype:    void    ComputeSourceVector(double WaveNum, double *MidPoint, complex *EiC)
Description:     To compute the E fields of an incident plane wave at the boundary surface.
Input value: Return value: none
Global value used: none
Global value modified: none
Subroutines called:  none

(Click to go back to Table of Contents.)

 


ComputeTetraHedronVolume()

Prototype:    void    ComputeTetraHedronVolume(int TetHedNum, double **Cord, int **TGNodeNum,double *TVolume)
Description:    To calculate the volume of a tetrahedron
Input value: Return value:     none
Global value used:     none
Global value modified:     none
Subroutines called:     VTXsub1()

(Click to go back to Table of Contents.)


ComputeTrngleCentroid()

Prototype:    void    ComputeTrngleCentroid( int TrngleNum, double **Cord, int **BFaceNode, double **CenTroid)
Description:     To compute the centroid of a triangular patch.
Input value: Return value:    none
Global value used:    none
Global value modified:    none
Subroutines called:     VTXadd2()

(Click to go back to Table of Contents.)



ConjugateSolver()

Prototype:    void    ConjugateSolver(int MatrixSize, int *RowIIndex, int **RowICol, complex **RowIDat, complex *RHSVec, int ITmax, double TOL)
Description:     To solve a linear system using complex bi-conjugate gradient method.
Input value: Return value:     none
Global value used:     none
Global value modified:     none
Subroutines called:     CMPLX_Vector(), COMplex_Cmplx(), COMplex_Null(), COMplex_Sub(), COMplex_Conjg(), VectorNorm(), InnerProduct(), COMplex_Add(), COMplex_Div(), COMplex_Mul(),
Real_Div().

(Click to go back to Table of Contents.)



CreateRHSVector()

Prototype:    void    CreateRHSVector(int InnerEdgeNum, int BoundEdgeNum, int ForcdEdgeNum, complex **FCDMatrixData, complex **ForcdValue,complex *RHSVector)
Description:     To use boundary conditions to create the right-hand side vector. The final matrix equation is  [LHS][E]=[RHS]. After RHS is known,  [E] can be solved by using  ConjugateSolver() .
Input value: Return value: none
Global value used:     SourceType ,GdVector, TotInnerEdgeNum
Global value modified:     none
Subroutines called:     COMplex_Mul(), COMplex_Add(), COMplex_Null(), Real_Mul()
 
(Click to go back to Table of Contents.)


FEMMatrixCompute()

Prototype:    void    FemMatrixCompute(int NumOfTetElement, int MaxElementPerRow, int **TetEdge, int **GlobalEdgeEnds,double **NodeCord, complex *TParam, complex *Epsilon, int **GBLmatColAddr, complex **GBLmat, int *GBLmatColIndex, double *TetVolume)
Description:     To build the FEM matrix and store them using row-indexed scheme.
Input value: Return value:     void
Global value used:     none
Global value modified: none
Subroutines called:     VTXsub(), VTXcross(), Sign()

(Click to go back to Table of Contents.)
 



MatrixVectorProduct()

Prototype:  void MatrixVectorProduct(char S, int Size, complex *XVec, complex *AVec, int *RIIndex,int **RICol,complex **RIDat)
Description:    To multiply the final matrix equation { [FEM] +[Cdd] } with a vector.
Input value:

Return value:   none
Global value used:  Cdd
Global value modified:     none
Subroutines called:   COMplex_Add(), COMplex_Null(), COMplex_Mul(), COMplex_Conjg()

(Click to go back to Table of Contents.)



InnerProduct()

Prototype:     complex Inner_Prod( complex *AVec,  complex *BVec, int Size )
Description:    To compute the inner product of  two vectors of complex type.
Input value:

Return value:   return the inner product of the two vectors.
                         If B=(x1, x2, ... xn), A=(y1, y2, ..., yn),
                         The inner product is defined as   x1y1* + x2y2* + ... +xnyn*, where * denotes conjugate.
Global value used:  none
Global value modified:     none
Subroutines called:   COMplex_Add().

(Click to go back to Table of Contents.)



InvertMatrix()

Prototype:    void    InvertMatrix(complex **Qmat, int MatrixSize)
Description:    To invert a complex matrix. The results are stored in the input matrix, thus no additional memory needed.
Input value: Return value:     none
Global value used:     none
Global value modified:     none
Subroutines called:    COMplex_Abs(), COMplex_Div(), COMplex_Cmplx(), COMplex_Sub(), COMplex_Mul(), INT_Matrix(), free_INT_Matrix()
 
(Click to go back to Table of Contents.)

PartitionGlobalFEMMatrix()

Prototype:     void    PartitionGlobalFEMMatrix(int ** GBLmatColAddr, complex **GBLmat, int *GBLmatColIndex, int InnerEdgeNum, int BoundEdgeNum, int ForcdEdgeNum, int *InnerEdgeStat, int *BoundEdgeStat, int *ISourceEdgeStat, complex **LHSMatrixData, complex **FCDMatrixData, complex **Cdd )
Description:     Partition the FEM matrix in terms of the internal, boundary and far-field quantities
Input value: Return value:     none
Global value used:     GBLmatColAddr, GBLmat, GBLmatColIndex, TotInnerEdgeNUm, DielBoundEdgeNum, TotISourceEdgeNum, InnerEdgeStat, BoundEdgeStat, ISourceEdgeStat, LHSMatrixData, FCDMAtrixData, Cdd
Global value modified:     none
Subroutines called:     Search NonZeroElement(), COMplex_Add()

(Click to go back to Table of Contents.)


ReadInputFile()

Prototype:    void    ReadMeshFile()
Description:    To read data from an input  file, initialize global variables
Input value:     none
Return value:     none
Global value used:     TotEdgeNum, TotTetElement, TotNodeNum, TotTrngleNum, TotBoundEdgeNum, TotInnerEdgeNum, DielBoundEdgeNum, HybrdBoundEdgeNum, TrngleNode,TrngleEdge,NodeCord, TetNode, TetNode,Epsilon, TetEdge , GlobalEdgeEnds, PlusTrngleDet, PlusTrngleIndex,MinusTrngleDet, MinusTrngleIndex,InnerEdgeStat,BoundEdgeStat,SourceType,VsourceMag, VSourceNum, OperateFreq, VsourceEdge,VVal
Global value modified:     TotEdgeNum, TotTetElement, TotNodeNum, TotTrngleNum, TotBoundEdgeNum, TotInnerEdgeNum, DielBoundEdgeNum, HybrdBoundEdgeNum, TrngleNode,TrngleEdge,NodeCord, TetNode, TetNode,Epsilon, TetEdge , GlobalEdgeEnds, PlusTrngleDet, PlusTrngleIndex,MinusTrngleDet, MinusTrngleIndex,InnerEdgeStat,BoundEdgeStat,SourceType,VsourceMag, VSourceNum, OperateFreq, VsourceEdge,VVal
Subroutines called:     INT_Matrix(), INT_Vector()

(Click to go back to Table of Contents.)



PrintOutput()

Prototype:     void   PrintOutput()
Description:   To print out the field within the area specified by the input file .
Input value:     none
Return value:   none
Global value used:  InF, OutF, HybrdBoundEdgeNum, EdVector, JdVector, JcVector, GlobalEdgeEnds, HybrdBoundEdgeNum, TotInnerEdgeNum, NodeCord, RHSVector
Global value modified:     none
Subroutines called:  none

(Click to go back to Table of Contents.)
 


SearchNonZeroElement()

Prototype:    int    SearchNonZeroElement(int RowNum, int ColNum)
Description:     To search an element in the global FEM matrix. To conserve memory, only none-zero elements are stored in the FEM matrix using row-indexed scheme.  If the element is found, return the column index to the global FEM matrix. Otherwise, return -1.
Input value: Return value:  the column index to GBLmat.
Global value used: int *GBLmatColIndex, int *GBLmatColAddr
Global value modified: none
Subroutines called: none

(Click to go back to Table of Contents.)


SurfaceFieldCompute()

Prototype:  void  SurfaceFieldCompute()
Description:  To compute the equivalent surface current density (Jc and Jd )
Input value:  none
Return value:  none
Global value used:  TotInnerEdgeNum EdVector HybrdBoundEdgeNum,
                    JdVector, JcVector,TotExtMetalEdgeNum, Dcd,  EdVector,
Global value modified:  none
Subroutines called:   COMplex_Add(),COMplex_Mul()
 

(Click to go back to Table of Contents)



TetFaceAreaNormal()

Prototype:    void    TetFaceAreaNormal(int TrngleNum, double **Cord, int **BFaceNode, double **Normal, double *Area)
Description:     To compute the unit normal and the area of each face of the tetrahedron
Input value: Return value:    none
Global value used:     none
Global value modified:     none
Subroutines called:     VTXcross1(), VTXsub1(), VTXcross()

(Click to go back to Table of Contents.)



VectorNorm()

Prototype:    double VectorNorm(complex *Vec, int Size)
Description:     To compute the the Euclidean norm of a complex vector
Input value: Return value:    the Euclidean norm of the vector. If the vector is (x1, x2, ..., xn),
                          the norm is defined as sqrt( |x1|^2 +|x2|^2+...+|xn|^2).
Global value used:     none
Global value modified:     none
Subroutines called:     COMplex_Abs().

(Click to go back to Table of Contents.)