60 #if !defined(VINLINE_VCSM) 64 VASSERT(thee != VNULL);
71 VASSERT(thee != VNULL);
73 return thee->
nsqm[isimp];
80 VASSERT(thee != VNULL);
83 VASSERT(iatom < (thee->
nsqm)[isimp]);
91 VASSERT(thee != VNULL);
94 VASSERT(iatom < (thee->
nsqm)[isimp]);
95 return (thee->
sqm)[isimp][iatom];
102 VASSERT(thee != VNULL);
105 return (thee->
nqsm)[iatom];
112 VASSERT(thee != VNULL);
115 return Gem_SS(thee->
gm, (thee->
qsm)[iatom][isimp]);
122 VASSERT(thee != VNULL);
125 return (thee->
qsm)[iatom][isimp];
130 if (thee == VNULL)
return 0;
131 return Vmem_bytes(thee->
vmem);
140 thee = (
Vcsm*)Vmem_malloc(VNULL, 1,
sizeof(
Vcsm) );
141 VASSERT( thee != VNULL);
149 VASSERT( thee != VNULL );
152 thee->
vmem = Vmem_ctor(
"APBS:VCSM");
155 if( alist == VNULL) {
156 Vnm_print(2,
"Vcsm_ctor2: got null pointer to Valist object!\n");
161 Vnm_print(2,
"Vcsm_ctor2: got a null pointer to the Gem object!\n");
186 Vnm_print(2,
"Vcsm_init: Error! Got NULL thee!\n");
189 if (thee->
gm == VNULL) {
190 Vnm_print(2,
"Vcsm_init: Error! Got NULL thee->gm!\n");
193 thee->
nsimp = Gem_numSS(thee->
gm);
194 if (thee->
nsimp <= 0) {
195 Vnm_print(2,
"Vcsm_init: Error! Got %d simplices!\n", thee->
nsimp);
202 thee->
sqm = (
int**)Vmem_malloc(thee->
vmem, thee->
nsimp,
sizeof(
int *));
203 VASSERT(thee->
sqm != VNULL);
204 thee->
nsqm = (
int*)Vmem_malloc(thee->
vmem, thee->
nsimp,
sizeof(
int));
205 VASSERT(thee->
nsqm != VNULL);
206 for (isimp=0; isimp<thee->
nsimp; isimp++) (thee->
nsqm)[isimp] = 0;
209 for (iatom=0; iatom<thee->
natom; iatom++) {
213 for (isimp=0; isimp<thee->
nsimp; isimp++) {
214 simplex = Gem_SS(thee->
gm, isimp);
215 if (Gem_pointInSimplex(thee->
gm, simplex, position)) {
216 (thee->
nsqm)[isimp]++;
224 for (isimp=0; isimp<thee->
nsimp; isimp++) {
225 if ((thee->
nsqm)[isimp] > 0) {
226 thee->
sqm[isimp] = (
int*)Vmem_malloc(thee->
vmem, (thee->
nsqm)[isimp],
228 VASSERT(thee->
sqm[isimp] != VNULL);
233 for (isimp=0; isimp<thee->
nsimp; isimp++) {
235 simplex = Gem_SS(thee->
gm, isimp);
236 for (iatom=0; iatom<thee->
natom; iatom++) {
240 if (Gem_pointInSimplex(thee->
gm, simplex, position)) {
242 (thee->
sqm)[isimp][jsimp] = iatom;
251 thee->
qsm = (
int**)Vmem_malloc(thee->
vmem, thee->
natom,
sizeof(
int *));
252 VASSERT(thee->
qsm != VNULL);
253 thee->
nqsm = (
int*)Vmem_malloc(thee->
vmem, thee->
natom,
sizeof(
int));
254 VASSERT(thee->
nqsm != VNULL);
255 for (iatom=0; iatom<thee->
natom; iatom++) (thee->
nqsm)[iatom] = 0;
258 for (isimp=0; isimp<thee->
nsimp; isimp++) {
259 for (iatom=0; iatom<thee->
nsqm[isimp]; iatom++) {
260 jatom = thee->
sqm[isimp][iatom];
266 for (iatom=0; iatom<thee->
natom; iatom++) {
267 if (thee->
nqsm[iatom] == 0) {
268 Vnm_print(2,
"Vcsm_init: Atom %d not placed in simplex!\n", iatom);
274 for (iatom=0; iatom<thee->
natom; iatom++) {
275 thee->
qsm[iatom] = (
int*)Vmem_malloc(thee->
vmem, (thee->
nqsm)[iatom],
277 VASSERT(thee->
qsm[iatom] != VNULL);
278 thee->
nqsm[iatom] = 0;
281 for (isimp=0; isimp<thee->
nsimp; isimp++) {
282 for (iatom=0; iatom<thee->
nsqm[isimp]; iatom++) {
283 jatom = thee->
sqm[isimp][iatom];
284 thee->
qsm[jatom][thee->
nqsm[jatom]] = isimp;
293 if ((*thee) != VNULL) {
295 Vmem_free(VNULL, 1,
sizeof(
Vcsm), (
void **)thee);
303 if ((thee != VNULL) && thee->
initFlag) {
305 for (i=0; i<thee->
msimp; i++) {
306 if (thee->
nsqm[i] > 0) Vmem_free(thee->
vmem, thee->
nsqm[i],
307 sizeof(
int), (
void **)&(thee->
sqm[i]));
309 for (i=0; i<thee->
natom; i++) {
310 if (thee->
nqsm[i] > 0) Vmem_free(thee->
vmem, thee->
nqsm[i],
311 sizeof(
int), (
void **)&(thee->
qsm[i]));
313 Vmem_free(thee->
vmem, thee->
msimp,
sizeof(
int *),
314 (
void **)&(thee->
sqm));
315 Vmem_free(thee->
vmem, thee->
msimp,
sizeof(
int),
316 (
void **)&(thee->
nsqm));
317 Vmem_free(thee->
vmem, thee->
natom,
sizeof(
int *),
318 (
void **)&(thee->
qsm));
319 Vmem_free(thee->
vmem, thee->
natom,
sizeof(
int),
320 (
void **)&(thee->
nqsm));
323 Vmem_dtor(&(thee->
vmem));
329 int isimp, jsimp, iatom, jatom, atomID, simpID;
336 int *qParent, nqParent;
337 int **sqmNew, *nsqmNew;
338 int *affAtoms, nAffAtoms;
339 int *dnqsm, *nqsmNew, **qsmNew;
341 VASSERT(thee != VNULL);
346 isimp = thee->
nsimp + num - 1;
349 if (isimp > thee->
msimp) {
351 thee->
nsqm = (
int*)Vmem_realloc(thee->
vmem, thee->
msimp,
sizeof(
int),
352 (
void **)&(thee->
nsqm), isimp);
353 VASSERT(thee->
nsqm != VNULL);
354 thee->
sqm = (
int**)Vmem_realloc(thee->
vmem, thee->
msimp,
sizeof(
int *),
355 (
void **)&(thee->
sqm), isimp);
356 VASSERT(thee->
sqm != VNULL);
361 for (isimp = thee->
nsimp; isimp<thee->nsimp+num-1 ; isimp++) {
362 thee->
nsqm[isimp] = 0;
369 isimp = SS_id(simps[0]);
370 if (thee->
nsqm[isimp] == 0) {
371 for (isimp=1; isimp<num; isimp++) {
372 thee->
nsqm[SS_id(simps[isimp])] = 0;
379 isimp = SS_id(simps[0]);
380 nqParent = thee->
nsqm[isimp];
381 qParent = thee->
sqm[isimp];
383 sqmNew = (
int**)Vmem_malloc(thee->
vmem, num,
sizeof(
int *));
384 VASSERT(sqmNew != VNULL);
385 nsqmNew = (
int*)Vmem_malloc(thee->
vmem, num,
sizeof(
int));
386 VASSERT(nsqmNew != VNULL);
387 for (isimp=0; isimp<num; isimp++) nsqmNew[isimp] = 0;
391 for (iatom=0; iatom<nqParent; iatom++) {
393 atomID = qParent[iatom];
400 for (isimp=0; isimp<num; isimp++) {
401 simplex = simps[isimp];
402 if (Gem_pointInSimplex(thee->
gm, simplex, position)) {
413 for (isimp=0; isimp<num; isimp++) iatom += nsqmNew[isimp];
414 if (iatom < nqParent) {
415 Vnm_print(2,
"Vcsm_update: Lost %d (of %d) atoms!\n",
416 nqParent - iatom, nqParent);
421 for (isimp=0; isimp<num; isimp++) {
422 if (nsqmNew[isimp] > 0) {
423 sqmNew[isimp] = (
int*)Vmem_malloc(thee->
vmem, nsqmNew[isimp],
425 VASSERT(sqmNew[isimp] != VNULL);
430 for (isimp=0; isimp<num; isimp++) {
433 simplex = simps[isimp];
436 for (iatom=0; iatom<nqParent; iatom++) {
438 atomID = qParent[iatom];
441 if (Gem_pointInSimplex(thee->
gm, simplex, position)) {
442 sqmNew[isimp][jsimp] = atomID;
451 affAtoms = thee->
sqm[SS_id(simps[0])];
452 nAffAtoms = thee->
nsqm[SS_id(simps[0])];
458 dnqsm = (
int*)Vmem_malloc(thee->
vmem, nAffAtoms,
sizeof(
int));
459 VASSERT(dnqsm != VNULL);
460 nqsmNew = (
int*)Vmem_malloc(thee->
vmem, nAffAtoms,
sizeof(
int));
461 VASSERT(nqsmNew != VNULL);
462 qsmNew = (
int**)Vmem_malloc(thee->
vmem, nAffAtoms,
sizeof(
int*));
463 VASSERT(qsmNew != VNULL);
464 for (iatom=0; iatom<nAffAtoms; iatom++) {
466 atomID = affAtoms[iatom];
467 for (isimp=0; isimp<num; isimp++) {
468 for (jatom=0; jatom<nsqmNew[isimp]; jatom++) {
469 if (sqmNew[isimp][jatom] == atomID) dnqsm[iatom]++;
472 VASSERT(dnqsm[iatom] > -1);
475 for (iatom=0;iatom<nAffAtoms; iatom++) {
476 atomID = affAtoms[iatom];
477 qsmNew[iatom] = (
int*)Vmem_malloc(thee->
vmem,
478 (dnqsm[iatom] + thee->
nqsm[atomID]),
481 VASSERT(qsmNew[iatom] != VNULL);
485 for (isimp=0; isimp<num; isimp++) {
486 simpID = SS_id(simps[isimp]);
487 for (iatom=0; iatom<nsqmNew[isimp]; iatom++) {
488 atomID = sqmNew[isimp][iatom];
489 for (jatom=0; jatom<nAffAtoms; jatom++) {
490 if (atomID == affAtoms[jatom])
break;
492 if (jatom < nAffAtoms) {
493 qsmNew[jatom][nqsmNew[jatom]] = simpID;
499 for (iatom=0; iatom<nAffAtoms; iatom++) {
500 atomID = affAtoms[iatom];
501 for (isimp=0; isimp<thee->
nqsm[atomID]; isimp++) {
502 for (jsimp=0; jsimp<num; jsimp++) {
503 simpID = SS_id(simps[jsimp]);
504 if (thee->
qsm[atomID][isimp] == simpID)
break;
507 qsmNew[iatom][nqsmNew[iatom]] = thee->
qsm[atomID][isimp];
515 for (iatom=0; iatom<nAffAtoms; iatom++) {
516 atomID = affAtoms[iatom];
517 Vmem_free(thee->
vmem, thee->
nqsm[atomID],
sizeof(
int),
518 (
void **)&(thee->
qsm[atomID]));
519 thee->
qsm[atomID] = qsmNew[iatom];
520 thee->
nqsm[atomID] = nqsmNew[iatom];
522 for (isimp=0; isimp<num; isimp++) {
523 simpID = SS_id(simps[isimp]);
524 if (thee->
nsqm[simpID] > 0) Vmem_free(thee->
vmem, thee->
nsqm[simpID],
525 sizeof(
int), (
void **)&(thee->
sqm[simpID]));
526 thee->
sqm[simpID] = sqmNew[isimp];
527 thee->
nsqm[simpID] = nsqmNew[isimp];
530 Vmem_free(thee->
vmem, num,
sizeof(
int *), (
void **)&sqmNew);
531 Vmem_free(thee->
vmem, num,
sizeof(
int), (
void **)&nsqmNew);
532 Vmem_free(thee->
vmem, nAffAtoms,
sizeof(
int *), (
void **)&qsmNew);
533 Vmem_free(thee->
vmem, nAffAtoms,
sizeof(
int), (
void **)&nqsmNew);
534 Vmem_free(thee->
vmem, nAffAtoms,
sizeof(
int), (
void **)&dnqsm);
Contains declarations for the Vcsm class.
VPUBLIC int Vcsm_getSimplexIndex(Vcsm *thee, int isimp, int iatom)
Get index particular simplex associated with an atom.
VPUBLIC Vcsm * Vcsm_ctor(Valist *alist, Gem *gm)
Construct Vcsm object.
VPUBLIC int Vcsm_update(Vcsm *thee, SS **simps, int num)
Update the charge-simplex and simplex-charge maps after refinement.
VPUBLIC int Vcsm_ctor2(Vcsm *thee, Valist *alist, Gem *gm)
FORTRAN stub to construct Vcsm object.
VPUBLIC int Vcsm_getNumberSimplices(Vcsm *thee, int iatom)
Get number of simplices associated with an atom.
VPUBLIC int Valist_getNumberAtoms(Valist *thee)
Get number of atoms in the list.
VPUBLIC SS * Vcsm_getSimplex(Vcsm *thee, int isimp, int iatom)
Get particular simplex associated with an atom.
VPUBLIC Vatom * Vcsm_getAtom(Vcsm *thee, int iatom, int isimp)
Get particular atom associated with a simplex.
VPUBLIC Valist * Vcsm_getValist(Vcsm *thee)
Get atom list.
VPUBLIC void Vcsm_dtor(Vcsm **thee)
Destroy Vcsm object.
Charge-simplex map class.
VPUBLIC Vatom * Valist_getAtom(Valist *thee, int i)
Get pointer to particular atom in list.
VPUBLIC int Vcsm_getAtomIndex(Vcsm *thee, int iatom, int isimp)
Get ID of particular atom in a simplex.
VPUBLIC double * Vatom_getPosition(Vatom *thee)
Get atomic position.
VPUBLIC unsigned long int Vcsm_memChk(Vcsm *thee)
Return the memory used by this structure (and its contents) in bytes.
Contains public data members for Vatom class/module.
Container class for list of atom objects.
VPUBLIC int Vcsm_getNumberAtoms(Vcsm *thee, int isimp)
Get number of atoms associated with a simplex.
VPUBLIC void Vcsm_init(Vcsm *thee)
Initialize charge-simplex map with mesh and atom data.
VPUBLIC void Vcsm_dtor2(Vcsm *thee)
FORTRAN stub to destroy Vcsm object.