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 "mulGlobal.h"
36 
main(argc,argv)37 main(argc, argv)
38 int argc;
39 char *argv[];
40 {
41   int ttliter, i, j, num_cond;
42   charge *chglist, *nq, *input_problem();
43   double *get_q();
44   ssystem *sys, *mulInit();
45   double **capmat, dirtimesav, mulsetup, initalltime, ttlsetup, ttlsolve;
46   double relperm;
47   int autmom, autlev, numMom, numLev;
48   char *fname, *concat3();
49 
50   extern int fulldirops, fullPqops;
51   extern int num_dummy_panels, num_dielec_panels;
52   extern int num_both_panels, num_cond_panels, up_size, eval_size;
53   extern char *title, *ps_file_base, *in_file_name;
54   extern long memcount;
55   extern double prectime, conjtime, dirtime, multime, uptime, downtime;
56   extern double evaltime, lutime, fullsoltime, prsetime;
57   extern char *kill_name_list;
58 
59   Name *name_list;
60 
61 #if DUMPPS == ON || DUMPPS == ALL
62   char filename[BUFSIZ];
63 #endif
64 
65 /*#if CAPVEW == ON*/
66   extern char **argvals;
67   extern int argcnt, m_, q_, dd_;
68   extern double ***axes;
69 /*#endif*/
70 
71   /* initialize memory and time counters, etc. */
72   fulldirops = fullPqops = 0;
73   prectime = conjtime = dirtime = multime = uptime = downtime = 0.0;
74   evaltime = lutime = fullsoltime = mulsetup = 0.0;
75   memcount = 0;
76   CALLOC(title, BUFSIZ, char, ON, AMSC);
77 
78   /* initialize defaults, etc */
79   autmom = autlev = ON;
80   relperm = 1.0;
81   argvals = argv;
82   argcnt = argc;
83   CALLOC(axes, 10, double **, ON, AMSC);
84   for(i = 0; i < 10; i++) {
85     CALLOC(axes[i], 2, double *, ON, AMSC);
86     for(j = 0; j < 2; j++) {
87       CALLOC(axes[i][j], 3, double, ON, AMSC);
88     }
89   }
90 
91   /* get the list of all panels in the problem */
92   /* - many command line parameters having to do with the postscript
93        file dumping interface are passed back via globals (see mulGlobal.c) */
94   chglist = input_problem(argv, argc, &autmom, &autlev, &relperm,
95 			  &numMom, &numLev, &name_list, &num_cond);
96 
97   /* just dump the psfile */
98     get_ps_file_base(argv, argc);
99     if (!q_) {
100       if (m_)
101         /* dump in matlab format */
102         dump_struct(chglist, NULL);
103       else {
104         /* dump a postscript file */
105         fprintf(stdout,"Creating postscript file\n");
106         dump_ps_geometry(chglist, NULL, 0, dd_);
107       }
108     }
109     else {
110       fname = concat3(in_file_name,"_","shadings");
111       if (m_)
112         /* dump in matlab format */
113         dump_struct(chglist, get_q(fname,chglist));
114       else {
115         /* dump in postscript format */
116         fprintf(stdout,"Creating postscript file with shading\n");
117         dump_ps_geometry(chglist, get_q(fname,chglist), 0, dd_);
118       }
119     }
120     exit(0);
121 
122 }
123 
concat3(st1,st2,st3)124 char *concat3(st1, st2, st3)
125 char *st1, *st2, *st3;
126 {
127   int length = 0;
128   char *allthree;
129 
130   length = strlen(st1);
131   length += strlen(st2);
132   length += strlen(st3);
133 
134   CALLOC(allthree, length+1, char, ON, AMSC);
135 
136   allthree[0] = '\0';
137   strcat(allthree,st1);
138   strcat(allthree,st2);
139   strcat(allthree,st3);
140 
141   return allthree;
142 }
143 
144 /*  For FastHenry, this reads the file of shadings for each of the faces */
145 
get_q(fname,chglist)146 double *get_q(fname, chglist)
147 char *fname;
148 charge *chglist;
149 {
150   FILE *fp;
151   int numchgs = 0;
152   charge *chg;
153   int error, i;
154   double *q;
155 
156   fp = fopen(fname, "r");
157   if (fp == NULL) {
158     printf("Couldn't open %s for -q option\n", fname);
159     exit(1);
160   }
161 
162   for(chg = chglist; chg != NULL; chg = chg->next)
163     numchgs++;
164 
165   CALLOC(q, numchgs, double, ON, AMSC);
166   error = 0;
167 
168   for(i = 0; i < numchgs && error == 0; i++) {
169     if (error == 0) {
170       if (fscanf(fp, "%lf", &q[i]) != 1) {
171         error = 1;
172         fprintf(stderr, "Error reading shading file. Rest of panels: q = 0\n");
173       }
174     }
175     else
176       q[i] = 0.0;
177   }
178 
179   return q;
180 
181 }
182