59 VPRIVATE
int Vpee_userDefined(
Vpee *thee,
62 VPRIVATE
int Vpee_ourSimp(
Vpee *thee,
66 VEXTERNC
double Aprx_estNonlinResid(Aprx *thee,
72 VEXTERNC
double Aprx_estLocalProblem(Aprx *thee,
77 VEXTERNC
double Aprx_estDualProblem(Aprx *thee,
102 thee = Vmem_malloc(VNULL, 1,
sizeof(
Vpee) );
103 VASSERT( thee != VNULL);
104 VASSERT(
Vpee_ctor2(thee, gm, localPartID, killFlag, killParam));
134 Vnm_print(0,
"Vpee_ctor2: No error attenuation outside partition.\n");
135 }
else if (killFlag == 1) {
136 Vnm_print(0,
"Vpee_ctor2: Error outside local partition ignored.\n");
137 }
else if (killFlag == 2) {
138 Vnm_print(0,
"Vpee_ctor2: Error ignored outside sphere with radius %4.3f times the radius of the circumscribing sphere\n", killParam);
139 if (killParam < 1.0) {
140 Vnm_print(2,
"Vpee_ctor2: Warning! Parameter killParam = %4.3 < 1.0!\n",
142 Vnm_print(2,
"Vpee_ctor2: This may result in non-optimal marking and refinement!\n");
144 }
else if (killFlag == 3) {
145 Vnm_print(0,
"Vpee_ctor2: Error outside local partition and immediate neighbors ignored [NOT IMPLEMENTED].\n");
147 Vnm_print(2,
"Vpee_ctor2: UNRECOGNIZED killFlag PARAMETER! BAILING!.\n");
152 thee->localPartID = localPartID;
153 thee->killFlag = killFlag;
154 thee->killParam = killParam;
155 thee->mem = Vmem_ctor(
"APBS::VPEE");
161 thee->localPartCenter[0] = 0.0;
162 thee->localPartCenter[1] = 0.0;
163 thee->localPartCenter[2] = 0.0;
165 for (ivert=0; ivert<Gem_numVV(thee->gm); ivert++) {
166 vert = Gem_VV(thee->gm, ivert);
167 simp = VV_firstSS(vert);
168 VASSERT(
simp != VNULL);
169 while (
simp != VNULL) {
170 if (SS_chart(
simp) == thee->localPartID) {
171 thee->localPartCenter[0] += VV_coord(vert, 0);
172 thee->localPartCenter[1] += VV_coord(vert, 1);
173 thee->localPartCenter[2] += VV_coord(vert, 2);
180 VASSERT(nLocalVerts > 0);
181 thee->localPartCenter[0] =
182 thee->localPartCenter[0]/((double)(nLocalVerts));
183 thee->localPartCenter[1] =
184 thee->localPartCenter[1]/((double)(nLocalVerts));
185 thee->localPartCenter[2] =
186 thee->localPartCenter[2]/((double)(nLocalVerts));
187 Vnm_print(0,
"Vpee_ctor2: Part %d centered at (%4.3f, %4.3f, %4.3f)\n",
188 thee->localPartID, thee->localPartCenter[0], thee->localPartCenter[1],
189 thee->localPartCenter[2]);
195 thee->localPartRadius = 0.0;
196 for (ivert=0; ivert<Gem_numVV(thee->gm); ivert++) {
197 vert = Gem_VV(thee->gm, ivert);
198 simp = VV_firstSS(vert);
199 VASSERT(
simp != VNULL);
200 while (
simp != VNULL) {
201 if (SS_chart(
simp) == thee->localPartID) {
202 dx = thee->localPartCenter[0] - VV_coord(vert, 0);
203 dy = thee->localPartCenter[1] - VV_coord(vert, 1);
204 dz = thee->localPartCenter[2] - VV_coord(vert, 2);
205 radius = dx*dx + dy*dy + dz*dz;
206 if (radius > thee->localPartRadius) thee->localPartRadius =
213 thee->localPartRadius = VSQRT(thee->localPartRadius);
214 Vnm_print(0,
"Vpee_ctor2: Part %d has circumscribing sphere of radius %4.3f\n",
215 thee->localPartID, thee->localPartRadius);
280 if ( ! ((-1 <= akey) && (akey <= 4)) ) {
281 Vnm_print(0,
"Vpee_markRefine: bad refine key; simplices marked = %d\n",
287 if ((-1 <= akey) && (akey <= 0)) {
288 marked = Gem_markRefine(thee->gm, akey, rcol);
294 Vnm_print(0,
"Vpee_estRefine: using Aprx_estNonlinResid().\n");
295 }
else if (akey == 3) {
296 Vnm_print(0,
"Vpee_estRefine: using Aprx_estLocalProblem().\n");
297 }
else if (akey == 4) {
298 Vnm_print(0,
"Vpee_estRefine: using Aprx_estDualProblem().\n");
300 Vnm_print(0,
"Vpee_estRefine: bad key given; simplices marked = %d\n",
304 if (thee->killFlag == 0) {
305 Vnm_print(0,
"Vpee_markRefine: No error attenuation -- simplices in all partitions will be marked.\n");
306 }
else if (thee->killFlag == 1) {
307 Vnm_print(0,
"Vpee_markRefine: Maximum error attenuation -- only simplices in local partition will be marked.\n");
308 }
else if (thee->killFlag == 2) {
309 Vnm_print(0,
"Vpee_markRefine: Spherical error attenutation -- simplices within a sphere of %4.3f times the size of the partition will be marked\n",
311 }
else if (thee->killFlag == 2) {
312 Vnm_print(0,
"Vpee_markRefine: Neighbor-based error attenuation -- simplices in the local and neighboring partitions will be marked [NOT IMPLEMENTED]!\n");
315 Vnm_print(2,
"Vpee_markRefine: bogus killFlag given; simplices marked = %d\n",
321 mlevel = (etol*etol) / Gem_numSS(thee->gm);
323 barrier = (etol*etol);
324 Vnm_print(0,
"Vpee_estRefine: forcing [err per S] < [TOL] = %g\n",
326 }
else if (bkey == 1) {
328 Vnm_print(0,
"Vpee_estRefine: forcing [err per S] < [(TOL^2/numS)^{1/2}] = %g\n",
331 Vnm_print(0,
"Vpee_estRefine: bad bkey given; simplices marked = %d\n",
337 Vnm_tstart(30,
"error estimation");
344 if (Gem_numSQ(thee->gm,currentQ) > 0) {
345 Vnm_print(0,
"Vpee_markRefine: non-empty refinement Q%d....clearing..",
347 Gem_resetSQ(thee->gm,currentQ);
348 Vnm_print(0,
"..done.\n");
350 if (Gem_numSQ(thee->gm,!currentQ) > 0) {
351 Vnm_print(0,
"Vpee_markRefine: non-empty refinement Q%d....clearing..",
353 Gem_resetSQ(thee->gm,!currentQ);
354 Vnm_print(0,
"..done.\n");
356 VASSERT( Gem_numSQ(thee->gm,currentQ) == 0 );
357 VASSERT( Gem_numSQ(thee->gm,!currentQ) == 0 );
360 Vnm_print(0,
"Vpee_markRefine: clearing all simplex refinement flags..");
361 for (i=0; i<Gem_numSS(thee->gm); i++) {
362 if ( (i>0) && (i % VPRTKEY) == 0 ) Vnm_print(0,
"[MS:%d]",i);
363 sm = Gem_SS(thee->gm,i);
364 SS_setRefineKey(sm,currentQ,0);
365 SS_setRefineKey(sm,!currentQ,0);
366 SS_setRefinementCount(sm,0);
368 Vnm_print(0,
"..done.\n");
372 if (akey == -1)
return marked;
374 if ((akey == 0) || (akey == 1)) {
376 while ( smid < Gem_numSS(thee->gm)) {
378 sm = Gem_SS(thee->gm,smid);
379 markMe = Vpee_ourSimp(thee, sm, rcol);
383 Gem_appendSQ(thee->gm,currentQ, sm);
384 SS_setRefineKey(sm,currentQ,1);
385 SS_setRefinementCount(sm,count);
386 }
else if (Vpee_userDefined(thee, sm)) {
388 Gem_appendSQ(thee->gm,currentQ, sm);
389 SS_setRefineKey(sm,currentQ,1);
390 SS_setRefinementCount(sm,count);
402 Vnm_print(0,
"Vpee_markRefine: estimating error..");
404 while ( smid < Gem_numSS(thee->gm)) {
407 sm = Gem_SS(thee->gm,smid);
408 markMe = Vpee_ourSimp(thee, sm, rcol);
410 if ( (smid>0) && (smid % VPRTKEY) == 0 ) Vnm_print(0,
"[MS:%d]",smid);
415 errEst = Aprx_estNonlinResid(aprx, sm, am->u,am->ud,am->f);
416 }
else if (akey == 3) {
417 errEst = Aprx_estLocalProblem(aprx, sm, am->u,am->ud,am->f);
418 }
else if (akey == 4) {
419 errEst = Aprx_estDualProblem(aprx, sm, am->u,am->ud,am->f);
421 VASSERT( errEst >= 0. );
424 if ( errEst > barrier ) {
426 Gem_appendSQ(thee->gm,currentQ, sm);
427 SS_setRefineKey(sm,currentQ,1);
428 SS_setRefinementCount(sm,count);
432 minError = VMIN2( VSQRT(VABS(errEst)), minError );
433 maxError = VMAX2( VSQRT(VABS(errEst)), maxError );
436 Bvec_set( aprx->wev, smid, errEst );
439 aprx->gerror += errEst;
443 Bvec_set( aprx->wev, smid, 0. );
450 Vnm_print(0,
"..done. [marked=<%d/%d>]\n",marked,Gem_numSS(thee->gm));
451 Vnm_print(0,
"Vpee_estRefine: TOL=<%g> Global_Error=<%g>\n",
453 Vnm_print(0,
"Vpee_estRefine: (TOL^2/numS)^{1/2}=<%g> Max_Ele_Error=<%g>\n",
454 VSQRT(mlevel),maxError);
455 Vnm_tstop(30,
"error estimation");
458 if ((bkey == 1) && (aprx->gerror <= etol)) {
460 "Vpee_estRefine: *********************************************\n");
462 "Vpee_estRefine: Global Error criterion met; setting marked=0.\n");
464 "Vpee_estRefine: *********************************************\n");
550 VASSERT(rcol == thee->localPartID);
555 for (ivert=0; ivert<SS_dimVV(sm); ivert++) {
556 dx = VV_coord(SS_vertex(sm, ivert), 0) -
557 thee->localPartCenter[0];
558 dy = VV_coord(SS_vertex(sm, ivert), 1) -
559 thee->localPartCenter[1];
560 dz = VV_coord(SS_vertex(sm, ivert), 2) -
561 thee->localPartCenter[2];
562 dist = VSQRT((dx*dx + dy*dy + dz*dz));
564 if (dist < thee->localPartRadius*thee->killParam)
return 1;
566 }
else if (thee->killFlag == 3) VASSERT(0);
Contains declarations for class Vpee.
VPUBLIC int Vpee_ctor2(Vpee *thee, Gem *gm, int localPartID, int killFlag, double killParam)
FORTRAN stub to construct the Vpee object.
Contains public data members for Vpee class/module.