1 /*
2 Copyright (c) 1990 Massachusetts Institute of Technology, Cambridge, MA.
3 All rights reserved.
4 
5 This Agreement gives you, the LICENSEE, certain rights and obligations.
6 By using the software, you indicate that you have read, understood, and
7 will comply with the terms.
8 
9 Permission to use, copy and modify for internal, noncommercial purposes
10 is hereby granted.  Any distribution of this program or any part thereof
11 is strictly prohibited without prior written consent of M.I.T.
12 
13 Title to copyright to this software and to any associated documentation
14 shall at all times remain with M.I.T. and LICENSEE agrees to preserve
15 same.  LICENSEE agrees not to make any copies except for LICENSEE'S
16 internal noncommercial use, or to use separately any portion of this
17 software without prior written consent of M.I.T.  LICENSEE agrees to
18 place the appropriate copyright notice on any such copies.
19 
20 Nothing in this Agreement shall be construed as conferring rights to use
21 in advertising, publicity or otherwise any trademark or the name of
22 "Massachusetts Institute of Technology" or "M.I.T."
23 
24 M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By
25 way of example, but not limitation, M.I.T. MAKES NO REPRESENTATIONS OR
26 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
27 THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS OR DOCUMENTATION WILL
28 NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
29 M.I.T. shall not be held liable for any liability nor for any direct,
30 indirect or consequential damages with respect to any claim by LICENSEE
31 or any third party on account of or arising from this Agreement or use
32 of this software.
33 */
34 
35 #include "patran.h"		/* for neutral file interface */
36 
37 struct surface {                /* a surface file and its permittivities */
38   int type;                     /* CONDTR, DIELEC or BOTH */
39   double trans[3];              /* translation vector applied to surface */
40   double ref[3];                /* reference point for normal alignment */
41   int ref_inside;               /* TRUE=>ref point inside (on - side of) surf*/
42   int end_of_chain;             /* TRUE=>end o/surf chain all w/same cond#'s */
43   char *title;			/* title inside surface file */
44   char *name;                   /* surface file name (neutral or quick fmat) */
45   char *group_name;		/* name of cond group (if any) surf part of */
46   double outer_perm;            /* relative permitivity on side n pnts into
47                                    (n is taken as the normal to 1st panel) */
48   double inner_perm;            /* relative permitivity on other side
49                                    (always zero for type = CONDTR) */
50   struct charge *panels;        /* linked list of panels on this surface */
51   int num_panels;               /* number of panels (incl dummies) this surf */
52   int num_dummies;              /* number of dummy panels on this surf */
53   struct surface *next;         /* linked list pointers */
54   struct surface *prev;
55 };
56 typedef struct surface surface;
57 
58 struct charge {			/* point charge */
59   struct charge *next;		/* Next charge in linked list. */
60   double corner[4][3];		/* Corner point coordinates. */
61   int shape;                    /* 4=quad panel, 3 = triangular panel. */
62   int index;			/* charge value index in q array */
63   double X[3], Y[3], Z[3];	/* Def coord system, Z is normal direction. */
64   double max_diag;		/* Longest diagonal of panel. */
65   double min_diag;		/* Shortest diagonal. */
66   double length[4];		/* Edge lengths. */
67   double area;			/* Area of two triangluar regions. */
68   double x, y, z;		/* Centroid of the quadlrilateral.  */
69   double moments[16];		/* Moments of the panel. */
70   double *multipole;		/* Temporarily Stores Q2M. */
71   int cond;                     /* Conductor number. */
72   int order;			/* Multipole order. */
73   /* things needed to do electric field evaluation by divided difference */
74   int dummy;                    /* TRUE => dummy panel for elec field eval */
75   struct surface *surf;         /* surface that contains this panel */
76   struct charge *pos_dummy;     /* eval pnt w/pos displacement from x,y,z */
77   struct charge *neg_dummy;     /* eval pnt w/neg displacement from x,y,z */
78 };
79 typedef struct charge charge;
80 
81 struct cube {
82 /* Definition variables. */
83   int index;			/* unique index */
84   int level;			/* 0 => root */
85   double x, y, z;		/* Position of cube center. */
86   int j, k, l;			/* cube is cubes[level][j][k][l] */
87   int flag;			/* used for marking for tree walks */
88 
89 /* Upward Pass variables. */
90   int mul_exact;                /* TRUE => do not build a multipole expansn */
91   struct cube *mnext;		/* Ptr to next cube on which to do multi. */
92   int upnumvects;		/* 0 if empty,  1 on bot level if not empty,
93 				   else # nonempty kids. */
94   int *upnumeles;		/* numeles[0] = # chgs on bot level, else
95 				   number of terms in kid's expansion. */
96   double **upvects;     /* vects[0] = chgs on bot level, else vectors
97                                     of kids' expansion terms. */
98   int multisize;        /* Number of terms in the expansion. */
99   double *multi;        /* Vector of multi coefficients. */
100   double ***upmats;     /* Matrices for chgs to multi or multi to multi.
101                            upmats[i] is multisize x upnumeles[i]. */
102   int *is_dummy;        /* is_dummy[i] = TRUE => panel i is a dummy panel
103                            used for elec field eval - omit from upward pass */
104   int *is_dielec;		/* is_dielec[i] = TRUE => panel i is on a surf
105 				   of type DIELEC or BOTH */
106 
107 /* Downward Pass variables. */
108   int loc_exact;                /* TRUE => do not build a local expansion */
109   struct cube *lnext;          /* Ptr to next cube on which to do local. */
110   int downnumvects;		/* Number of cubes in iteraction list. */
111   int *downnumeles;		/* # of eles in interact cube's expansion. */
112   double **downvects;		/* Vects of interact cube's expansion. */
113 
114   int localsize;        /* Size of the local expansion */
115   double *local;        /* Vector of local field coefs */
116   double ***downmats;   /* Matrices for multi to chg, or multi to local
117 			   or local to local.  Downnumele x localsize. */
118 
119   struct cube **interList;	/* explicit interaction list
120 				   - for fake dwnwd passes and eval pass */
121   int interSize;		/* number of elements in interList
122 				   - often != downnumvects nor evalnumvects */
123 
124   /* evaluation pass variables */
125   struct cube *enext;		/* pntr to next cube to evaluate */
126   int evalnumvects;		/* for exact = #in inter list, o.w. = 1 */
127   int *evalnumeles;		/* num of elements in inter list entry exp */
128   double **evalvects;		/* multi, local, or chgs of ilist entry */
129 
130   double *eval;			/* vector of evaluation pnt voltages in cube */
131   double ***evalmats;		/* matrices for multi to potential, local to
132 				   potential or charge to potential */
133 
134 /* Direct portion variables. */
135   struct cube *dnext;		/* Ptr to next cube on which to do direct. */
136   struct cube *pnext;		/* Ptr to next cube on which to do precond. */
137   struct cube *rpnext;		/* Reverse ptr to next cube to do precond. */
138   int dindex;			/* Used to determine lower triang portion. */
139   int directnumvects;		/* Number of vects, self plus nbrs. */
140   int *directnumeles;		/* # of elements in the nbrs chg vect.
141 				   directnumeles[0] = numchgs in cube. */
142   double **directq;		/* Vecs of chg vecs, directq[0] this cube's. */
143   double ***directmats;		/* Potential Coeffs in cube and neighbors. */
144   double ***precondmats;	/* Precond Coeffs in cube and neighbors. */
145   double **directlu;		/* Decomposed cube potential Coefficients. */
146   double **precond;		/* Preconditioner. */
147   double *prevectq;		/* The charge vector for the preconditioner. */
148   double *prevectp;		/* The potential vector for preconditioner. */
149   int presize;			/* Size of the preconditioner. */
150   int **nbr_is_dummy;		/* Dummy vectors corresponding to directq's */
151 
152 /* Cube structure variables. */
153   charge **chgs;          /* Array of charge ptrs. Only used lowest level. */
154   struct cube **nbrs;     /* Array of ptrs to nonemptry nearest neighbors. */
155   int numnbrs;            /* Number of nonempty neighbors. */
156   struct cube **kids;     /* Array of children ptrs. */
157   int numkids;            /* Number of kids. */
158   struct cube *parent;    /* Ptr to parent cube. */
159 
160 };
161 typedef struct cube cube;
162 
163 struct ssystem {
164   int side;                     /* # cubes per side on lowest level. */
165   int depth;			/* # of levels of cubes. */
166   int order;			/* # of levels of cubes. */
167   int num_cond;                 /* number of conductors */
168   Name *cond_names;		/* conductor name list */
169   double perm_factor;           /* overall scale factor for permittivities */
170   double length;		/* Length per cube on lowest level. */
171   double minx, miny, minz;	/* Coordinates of one corner of the domain. */
172   int mul_maxq;                 /* max #panels in mul_exact cube */
173   int mul_maxlq;                /* max #panels in lowest level cube */
174   int max_panel;                /* max #panels in all cubes w/multipole */
175   int up_size;                  /* total #panels in all cubes, incl dummies */
176   int loc_maxq;                 /* max #evaluation points in loc_exact cube */
177   int loc_maxlq;                /* max #eval pnts in lowest level cube. */
178   int max_eval_pnt;             /* max #eval pnts in all cubes w/local exp */
179   int eval_size;                /* total #eval pnts in entire problem */
180   double *q;                    /* The vector of lowest level charges. */
181   double *p;                    /* The vector of lowest level potentials. */
182   charge *panels;               /* linked list of charge panels in problem */
183   cube *****cubes;		/* The array of cube pointers. */
184   cube **multilist;             /* Array of ptrs to first cube in linked list
185 				   of cubes to do multi at each level. */
186   cube **locallist;             /* Array of ptrs to first cube in linked list
187 				   of cubes to do local at each level. */
188   cube *directlist;		/* head of linked lst of low lev cubes w/chg */
189   cube *precondlist;		/* head of linked lst of precond blks. */
190   cube *revprecondlist;		/* reversed linked lst of precond blks. */
191   int *is_dummy;                /* is_dummy[i] = TRUE => panel i is a dummy */
192   int *is_dielec;		/* is_dielec[i] = TRUE => panel i on dielec */
193 };
194 typedef struct ssystem ssystem;
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206