Next: Examples
Contents
This Section describes the structure of the code and explains the function of various subroutines. EMAP4 is a complex-valued vector finite element code. The code is written in the ``C'' language. The code can be divided into three parts:
The pre-processing part: The code first reads the input file and checks for errors and inconsistencies and configurations that cannot be modeled. Then it allocates the memory. and initializes the variables. The mesh generation is also done in this part.
The finite element part: Once the meshing is complete, the code evaluates the various finite element matrices. First, the finite element matrix for each tetrahedron is calculated. This matrix consists of two parts, a part just dependent on the geometry and a second part dependent on the frequency and the relative permittivities. These tetrahedron matrices are then assembled into a global matrix. The global matrix equation is then partitioned by taking all the forced (known) variables to the right hand side (see Section 2). This system now can be solved for the unknown variables (see Section 7).
The post-processing part: Once the electric fields are known along all the mesh edges, they can be output in the default form, i.e. a listing of all the edges and the electric fields. If the keyword "efield_output" is present in the input file, the fields at required nodes are calculated and written to a file.
A brief description of each routine is given below. A clickable flowchart is provided.
The following are the preprocessing routines.
Main() - This is the main routine which calls all the other routines. This routine also allocates most of the memory and initializes all the variables.
Read_Input_Pass_1() - This routine reads the input file the first time and checks for errors and inconsistencies. It also reads into memory the cell dimensions and frequency of operation.
Parameter_Info() - This routine calculates the values of various constants, for example, wave number etc. It also calculates various numbers required in the program, for example, total number of edges, number of bricks (hexahedra) etc.
Read_Input_Pass_2() - Reads the input file a second time and initializes all the variables. It first calls a function edge(). This routine calculates the relationship between the local edge number and global edge number for all the edges in each hexahedron. Then it calls deter_edge(), a routine which locates all the boundary edges. Read_Input_Pass_2() initializes the electric fields at all the forced edges and also the boundary edges using the information given in the input files. It finally calls a routine CountEdgeType(), which counts the number of forced edges, unforced (or inner edges) and boundary edges.
An important part of the preprocessing is the mesh generation.
AssignGlobalCoordinates() - This is the first step in the meshing process. The whole area of interest is subdivided into hexahedra and the nodes are assigned global coordinates in this routine.
AssignHexHedronNodeNumbering() - This routine assigns global node numbers for each node in the mesh.
AssignHexHedronEdgeNumbering() - This routine assigns global edge numbers for each edge in the mesh.
HexHedSubDiv1() & HexHedSubDiv2() - These routines subdivide each hexahedron into five tetrahedra in two different ways.
EdgeSubDiv1() & EdgeSubDiv2()- These routines assign global edge numbers to the edges of each tetrahedron. EdgeSubDiv1() is used if HexHedSubDiv1() was used and similarly for EdgeSubDiv2().
GlobalEdgeEndsDiv1() & GlobalEdgeEndsDiv2()- These routines assign global end nodes to the edges of each tetrahedron. GlobalEdgeEndsDiv1() is used if HexHedSubDiv1() was used and similarly for GlobalEdgeEndsDiv2(). At this point, the meshing of the area of interest is complete.
The next step is to calculate the global matrix. The following five routines are run for each tetrahedron (see Appendices A and B in [9] for the matrix calculation).
FindTetraHedronVolume() - This routine calculates the volume of the given tetrahedron.
ComputeTetraCoFactor() - This routine calculates the cofactor matrix of the tetrahedron.
S_Matrix() - This routine calculates part of the tetrahedron matrix. (Eij in [9])
T_matrix() - This routine calculates another part of the tetrahedron. (Fij in [9])
TetraSubMatrix() - The final tetrahedron matrix is assembled in this routine.
FindGlobalMatrix() - This routine assembles the individual tetrahedron matrices into the global matrix.
PartitionGlobalMatrix() - This routine partitions the global matrix into the LHS (containing the unknown variables) and the RHS (containing the forced variables).
ConjugateSolver() - This routine solves the resulting matrix equation. The method used to solve this equation is the Complex Biconjugate Gradient (CBCG) method.
The post-processing is done using the following routine.
Produce_Output() - This routine writes out the output in the required and the default forms specified by the user in the input file. This routine calls Efield_Data() to compute the electric field values at the nodes.