APBS
3.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
bemparm.c
Go to the documentation of this file.
1
56
57
#include "bemparm.h"
58
59
VEMBED
(rcsid=
"$Id$"
)
60
61
#if !defined(VINLINE_MGPARM)
62
63
#endif
/* if !defined(VINLINE_MGPARM) */
64
65
66
VPUBLIC
BEMparm
*
BEMparm_ctor
(
BEMparm_CalcType
type) {
67
68
/* Set up the structure */
69
BEMparm
*thee = VNULL;
70
thee = (
BEMparm
*)Vmem_malloc(VNULL, 1,
sizeof
(
BEMparm
));
71
VASSERT( thee != VNULL);
72
VASSERT(
BEMparm_ctor2
(thee, type) ==
VRC_SUCCESS
);
73
74
return
thee;
75
}
76
77
VPUBLIC Vrc_Codes
BEMparm_ctor2
(
BEMparm
*thee,
BEMparm_CalcType
type) {
78
79
int
i;
80
81
if
(thee == VNULL)
return
VRC_FAILURE
;
82
83
thee->
parsed
= 0;
84
thee->
type
= type;
85
86
/* *** GENERIC PARAMETERS *** */
87
88
/* *** TYPE 0 PARAMETERS *** */
89
thee->
tree_order
= 1;
90
thee->
settree_order
= 0;
91
thee->
tree_n0
= 500;
92
thee->
settree_n0
= 0;
93
thee->
mac
= 0.8;
94
thee->
setmac
= 0;
95
96
thee->
mesh
= 0;
97
thee->
setmesh
= 0;
98
99
thee->
outdata
= 0;
100
thee->
setoutdata
= 0;
101
102
/* *** TYPE 1 & 2 PARAMETERS *** */
103
104
/* *** TYPE 2 PARAMETERS *** */
105
thee->
nonlintype
= 0;
106
thee->
setnonlintype
= 0;
107
108
/* *** Default parameters for TINKER *** */
109
thee->
chgs
=
VCM_CHARGE
;
110
111
return
VRC_SUCCESS
;
112
}
113
114
VPUBLIC
void
BEMparm_dtor
(
BEMparm
**thee) {
115
if
((*thee) != VNULL) {
116
BEMparm_dtor2
(*thee);
117
Vmem_free(VNULL, 1,
sizeof
(
BEMparm
), (
void
**)thee);
118
(*thee) = VNULL;
119
}
120
}
121
122
VPUBLIC
void
BEMparm_dtor2
(
BEMparm
*thee) { ; }
123
124
VPUBLIC Vrc_Codes
BEMparm_check
(
BEMparm
*thee) {
125
126
Vrc_Codes rc;
127
int
i, tdime[3], ti, tnlev[3], nlev;
128
129
rc =
VRC_SUCCESS
;
130
131
Vnm_print(0,
"BEMparm_check: checking BEMparm object of type %d.\n"
,
132
thee->
type
);
133
134
/* Check to see if we were even filled... */
135
if
(!thee->
parsed
) {
136
Vnm_print(2,
"BEMparm_check: not filled!\n"
);
137
return
VRC_FAILURE
;
138
}
139
140
141
/* Check type settings */
142
if
((thee->
type
!=
BCT_MANUAL
) && (thee->
type
!=
BCT_NONE
)) {
143
Vnm_print(2,
"BEMparm_check: type not set"
);
144
rc =
VRC_FAILURE
;
145
}
146
147
/* Check treecode setting*/
148
if
(thee->
tree_order
< 1) {
149
Vnm_print(2,
"BEMparm_check: treecode order is less than 1"
);
150
rc =
VRC_FAILURE
;
151
}
152
if
(thee->
tree_n0
< 1) {
153
Vnm_print(2,
"BEMparm_check: treecode leaf size is less than 1"
);
154
rc =
VRC_FAILURE
;
155
}
156
if
(thee->
mac
> 1 || thee->
mac
<= 0) {
157
Vnm_print(2,
"BEMparm_check: MAC criterion fails"
);
158
rc =
VRC_FAILURE
;
159
}
160
161
if
(thee->
mesh
> 2 || thee->
mesh
< 0) {
162
Vnm_print(2,
"BEMparm_check: mesh must be 0 (msms) or 1 and 2 (NanoShaper)"
);
163
rc =
VRC_FAILURE
;
164
}
165
166
if
(thee->
outdata
> 2 || thee->
outdata
< 0) {
167
Vnm_print(2,
"BEMparm_check: outdata must be 0, 1 (vtk), or 2 (not specified)"
);
168
rc =
VRC_FAILURE
;
169
}
170
171
return
rc;
172
}
173
174
VPUBLIC
void
BEMparm_copy
(
BEMparm
*thee,
BEMparm
*parm) {
175
176
int
i;
177
178
VASSERT(thee != VNULL);
179
VASSERT(parm != VNULL);
180
181
182
thee->
type
= parm->
type
;
183
thee->
parsed
= parm->
parsed
;
184
185
/* *** GENERIC PARAMETERS *** */
186
187
/* *** TYPE 0 PARMS *** */
188
189
thee->
tree_order
= parm->
tree_order
;
190
thee->
settree_order
= parm->
settree_order
;
191
thee->
tree_n0
= parm->
tree_n0
;
192
thee->
settree_n0
= parm->
settree_n0
;
193
thee->
mac
= parm->
mac
;
194
thee->
setmac
= parm->
setmac
;
195
196
thee->
mesh
= parm->
mesh
;
197
thee->
setmesh
= parm->
setmesh
;
198
199
thee->
outdata
= parm->
outdata
;
200
thee->
setoutdata
= parm->
setoutdata
;
201
202
/* *** TYPE 1 & 2 PARMS *** */
203
204
/* *** TYPE 2 PARMS *** */
205
thee->
nonlintype
= parm->
nonlintype
;
206
thee->
setnonlintype
= parm->
setnonlintype
;
207
}
208
209
210
VPRIVATE Vrc_Codes BEMparm_parseTREE_ORDER(
BEMparm
*thee, Vio *sock) {
211
212
char
tok[VMAX_BUFSIZE];
213
int
ti;
214
215
VJMPERR1(Vio_scanf(sock,
"%s"
, tok) == 1);
216
if
(sscanf(tok,
"%d"
, &ti) == 0) {
217
Vnm_print(2,
"NOsh: Read non-integer (%s) while parsing TREE_ORDER \
218
keyword!\n"
, tok);
219
return
VRC_WARNING;
220
}
else
if
(ti <= 0) {
221
Vnm_print(2,
"parseBEM: tree_order must be greater than 0!\n"
);
222
return
VRC_WARNING;
223
}
else
thee->
tree_order
= ti;
224
thee->
settree_order
= 1;
225
return
VRC_SUCCESS
;
226
227
VERROR1:
228
Vnm_print(2,
"parseBEM: ran out of tokens!\n"
);
229
return
VRC_WARNING;
230
}
231
232
233
VPRIVATE Vrc_Codes BEMparm_parseTREE_N0(
BEMparm
*thee, Vio *sock) {
234
235
char
tok[VMAX_BUFSIZE];
236
int
ti;
237
238
VJMPERR1(Vio_scanf(sock,
"%s"
, tok) == 1);
239
if
(sscanf(tok,
"%d"
, &ti) == 0) {
240
Vnm_print(2,
"NOsh: Read non-integer (%s) while parsing TREE_N0 \
241
keyword!\n"
, tok);
242
return
VRC_WARNING;
243
}
else
if
(ti <= 0) {
244
Vnm_print(2,
"parseBEM: tree_n0 must be greater than 0!\n"
);
245
return
VRC_WARNING;
246
}
else
thee->
tree_n0
= ti;
247
thee->
settree_n0
= 1;
248
return
VRC_SUCCESS
;
249
250
VERROR1:
251
Vnm_print(2,
"parseBEM: ran out of tokens!\n"
);
252
return
VRC_WARNING;
253
}
254
255
256
VPRIVATE Vrc_Codes BEMparm_parseMAC(
BEMparm
*thee, Vio *sock) {
257
258
char
tok[VMAX_BUFSIZE];
259
double
tf;
260
261
VJMPERR1(Vio_scanf(sock,
"%s"
, tok) == 1);
262
if
(sscanf(tok,
"%lf"
, &tf) == 0) {
263
Vnm_print(2,
"NOsh: Read non-float (%s) while parsing mac \
264
keyword!\n"
, tok);
265
return
VRC_WARNING;
266
}
else
if
(tf <= 0.0 || tf > 1.0) {
267
Vnm_print(2,
"parseBEM: mac must be between 0 and 1!\n"
);
268
return
VRC_WARNING;
269
}
else
thee->
mac
= tf;
270
thee->
setmac
= 1;
271
return
VRC_SUCCESS
;
272
273
VERROR1:
274
Vnm_print(2,
"parseBEM: ran out of tokens!\n"
);
275
return
VRC_WARNING;
276
}
277
278
279
VPRIVATE Vrc_Codes BEMparm_parseMESH(
BEMparm
*thee, Vio *sock) {
280
281
char
tok[VMAX_BUFSIZE];
282
283
VJMPERR1(Vio_scanf(sock,
"%s"
, tok) == 1);
284
if
(strcmp(tok,
"msms"
) == 0){
285
thee->
mesh
= 0;
286
}
287
else
if
(strcmp(tok,
"ses"
) == 0){
288
thee->
mesh
= 1;
289
}
290
else
if
(strcmp(tok,
"skin"
) == 0){
291
thee->
mesh
= 2;
292
}
293
else
{
294
Vnm_print(2,
"parseBEM: mesh option %s is not recognized! It must be one of msms, \
295
ses, or skin.\n"
, tok);
296
return
VRC_WARNING;
297
}
298
299
thee->
setmesh
= 1;
300
return
VRC_SUCCESS
;
301
302
VERROR1:
303
Vnm_print(2,
"parseBEM: ran out of tokens!\n"
);
304
return
VRC_WARNING;
305
}
306
307
308
VPRIVATE Vrc_Codes BEMparm_parseOUTDATA(
BEMparm
*thee, Vio *sock) {
309
310
char
tok[VMAX_BUFSIZE];
311
int
ti;
312
313
VJMPERR1(Vio_scanf(sock,
"%s"
, tok) == 1);
314
if
(sscanf(tok,
"%d"
, &ti) == 0) {
315
Vnm_print(2,
"NOsh: Read non-integer (%s) while parsing OUTDATA \
316
keyword!\n"
, tok);
317
return
VRC_WARNING;
318
}
else
if
(ti < 0 || ti > 2) {
319
Vnm_print(2,
"parseBEM: outdata must be 0, 1 (vtk), \
320
or 2 (unspecified)!\n"
);
321
return
VRC_WARNING;
322
}
else
thee->
outdata
= ti;
323
thee->
setoutdata
= 1;
324
return
VRC_SUCCESS
;
325
326
VERROR1:
327
Vnm_print(2,
"parseBEM: ran out of tokens!\n"
);
328
return
VRC_WARNING;
329
}
330
331
332
VPUBLIC Vrc_Codes
BEMparm_parseToken
(
BEMparm
*thee,
char
tok[VMAX_BUFSIZE],
333
Vio *sock) {
334
335
if
(thee == VNULL) {
336
Vnm_print(2,
"parseBEM: got NULL thee!\n"
);
337
return
VRC_WARNING;
338
}
339
if
(sock == VNULL) {
340
Vnm_print(2,
"parseBEM: got NULL socket!\n"
);
341
return
VRC_WARNING;
342
}
343
344
Vnm_print(0,
"BEMparm_parseToken: trying %s...\n"
, tok);
345
346
347
if
(
Vstring_strcasecmp
(tok,
"tree_order"
) == 0) {
348
return
BEMparm_parseTREE_ORDER(thee, sock);
349
}
else
if
(
Vstring_strcasecmp
(tok,
"tree_n0"
) == 0) {
350
return
BEMparm_parseTREE_N0(thee, sock);
351
}
else
if
(
Vstring_strcasecmp
(tok,
"mac"
) == 0) {
352
return
BEMparm_parseMAC(thee, sock);
353
}
else
if
(
Vstring_strcasecmp
(tok,
"mesh"
) == 0) {
354
return
BEMparm_parseMESH(thee, sock);
355
}
else
if
(
Vstring_strcasecmp
(tok,
"outdata"
) == 0) {
356
return
BEMparm_parseOUTDATA(thee, sock);
357
}
else
{
358
Vnm_print(2,
"parseBEM: Unrecognized keyword (%s)!\n"
, tok);
359
return
VRC_WARNING;
360
}
361
362
return
VRC_FAILURE
;
363
364
}
BEMparm_copy
VPUBLIC void BEMparm_copy(BEMparm *thee, BEMparm *parm)
Copy object info into thee.
Definition
bemparm.c:174
BEMparm_parseToken
VPUBLIC Vrc_Codes BEMparm_parseToken(BEMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition
bemparm.c:332
BEMparm_dtor2
VPUBLIC void BEMparm_dtor2(BEMparm *thee)
FORTRAN stub for object destructor.
Definition
bemparm.c:122
BEMparm_CalcType
enum eBEMparm_CalcType BEMparm_CalcType
Declare BEMparm_CalcType type.
Definition
bemparm.h:86
BEMparm_ctor2
VPUBLIC Vrc_Codes BEMparm_ctor2(BEMparm *thee, BEMparm_CalcType type)
FORTRAN stub to construct BEMparm object.
Definition
bemparm.c:77
BEMparm
struct sBEMparm BEMparm
Parameter structure for BEM-specific variables from input files.
BEMparm_ctor
VPUBLIC BEMparm * BEMparm_ctor(BEMparm_CalcType type)
Construct BEMparm object.
Definition
bemparm.c:66
BEMparm_check
VPUBLIC Vrc_Codes BEMparm_check(BEMparm *thee)
Consistency check for parameter values stored in object.
Definition
bemparm.c:124
BEMparm_dtor
VPUBLIC void BEMparm_dtor(BEMparm **thee)
Object destructor.
Definition
bemparm.c:114
BCT_NONE
@ BCT_NONE
Definition
bemparm.h:79
BCT_MANUAL
@ BCT_MANUAL
Definition
bemparm.h:78
VEMBED
#define VEMBED(rctag)
Allows embedding of RCS ID tags in object files.
Definition
vhal.h:556
VCM_CHARGE
@ VCM_CHARGE
Definition
vhal.h:252
VRC_FAILURE
@ VRC_FAILURE
Definition
vhal.h:69
VRC_SUCCESS
@ VRC_SUCCESS
Definition
vhal.h:70
Vstring_strcasecmp
VPUBLIC int Vstring_strcasecmp(const char *s1, const char *s2)
Case-insensitive string comparison (BSD standard).
Definition
vstring.c:66
sBEMparm::outdata
int outdata
Definition
bemparm.h:116
sBEMparm::tree_n0
int tree_n0
Definition
bemparm.h:106
sBEMparm::chgs
Vchrg_Src chgs
Definition
bemparm.h:102
sBEMparm::setnonlintype
int setnonlintype
Definition
bemparm.h:111
sBEMparm::parsed
int parsed
Definition
bemparm.h:99
sBEMparm::type
BEMparm_CalcType type
Definition
bemparm.h:98
sBEMparm::setmesh
int setmesh
Definition
bemparm.h:114
sBEMparm::setmac
int setmac
Definition
bemparm.h:109
sBEMparm::tree_order
int tree_order
Definition
bemparm.h:104
sBEMparm::nonlintype
int nonlintype
Definition
bemparm.h:110
sBEMparm::settree_n0
int settree_n0
Definition
bemparm.h:107
sBEMparm::setoutdata
int setoutdata
Definition
bemparm.h:117
sBEMparm::settree_order
int settree_order
Definition
bemparm.h:105
sBEMparm::mesh
int mesh
Definition
bemparm.h:113
sBEMparm::mac
double mac
Definition
bemparm.h:108
src
generic
bemparm.c
Generated on
for APBS by
1.17.0