#include <GridForceGrid.h>
Inheritance diagram for GridforceLiteGrid:

Public Member Functions | |
| GridforceLiteGrid (int gridnum) | |
| virtual | ~GridforceLiteGrid () |
| void | initialize (char *potfilename, SimParameters *simParams, MGridforceParams *mgridParams) |
| void | reinitialize (SimParameters *simParams, MGridforceParams *mgridParams) |
| Position | get_center (void) const |
| Position | get_origin (void) const |
| Tensor | get_e (void) const |
| Tensor | get_inv (void) const |
| Vector | get_scale (void) const |
| int | get_k0 (void) const |
| int | get_k1 (void) const |
| int | get_k2 (void) const |
| int | get_total_grids (void) const |
| float | get_grid (int i0, int i1, int i2, int i3) const |
| double | get_grid_d (int i0, int i1, int i2, int i3) const |
| void | set_grid (int i0, int i1, int i2, int i3, float V) |
| int | get_all_gridvals (float **all_gridvals) const |
| void | set_all_gridvals (float *all_gridvals, int sz) |
| int | compute_VdV (Position pos, float &V, Vector &dV) const |
Protected Member Functions | |
| void | compute_derivative_grids (void) |
| void | compute_wts (float *wts, const Vector &dg) const |
| int | get_inds (Position pos, int *inds, Vector &dg) const |
| float | linear_interpolate (int i0, int i1, int i2, int i3, const float *wts) const |
| void | pack (MOStream *msg) const |
| void | unpack (MIStream *msg) |
| int | grid_index (int i0, int i1, int i2, int i3) const |
Protected Attributes | |
| float * | grid |
| int | k [4] |
| int | size |
| int | dk [4] |
| Position | origin |
| Position | center |
| Tensor | e |
| Tensor | inv |
| Vector | scale |
| char | filename [129] |
|
|
Definition at line 1291 of file GridForceGrid.C. References grid.
|
|
|
Definition at line 1299 of file GridForceGrid.C. 01300 {
01301 delete[] grid;
01302 }
|
|
|
Definition at line 1355 of file GridForceGrid.C. References DebugM, endi(), get_grid(), get_grid_d(), k, and set_grid(). Referenced by initialize(). 01356 {
01357 // calculate derivative grids
01358 // separate loop so all V values have been set already
01359 for (int i0 = 0; i0 < k[0]; i0++) {
01360 for (int i1 = 0; i1 < k[1]; i1++) {
01361 for (int i2 = 0; i2 < k[2]; i2++) {
01362 float dx, dy, dz;
01363 if (i0 == 0 || i0 == k[0]-1 || i1 == 0 || i1 == k[1]-1 || i2 == 0 || i2 == k[2]-1) {
01364 // on edge, set ALL derivatives to zero (make up for lack of padding)
01365 dx = 0;
01366 dy = 0;
01367 dz = 0;
01368 } else {
01369 dx = 0.5 * (get_grid_d(i0+1,i1,i2,0) - get_grid_d(i0-1,i1,i2,0));
01370 dy = 0.5 * (get_grid_d(i0,i1+1,i2,0) - get_grid_d(i0,i1-1,i2,0));
01371 dz = 0.5 * (get_grid_d(i0,i1,i2+1,0) - get_grid_d(i0,i1,i2-1,0));
01372 }
01373 set_grid(i0, i1, i2, 1, dx);
01374 set_grid(i0, i1, i2, 2, dy);
01375 set_grid(i0, i1, i2, 3, dz);
01376 DebugM(1, "dx[" << i0 << "," << i1 << "," << i2 << "] = " << get_grid(i0, i1, i2, 1) << "(" << dx << ")\n" << endi);
01377 DebugM(1, "dy[" << i0 << "," << i1 << "," << i2 << "] = " << get_grid(i0, i1, i2, 2) << "(" << dy << ")\n" << endi);
01378 DebugM(1, "dz[" << i0 << "," << i1 << "," << i2 << "] = " << get_grid(i0, i1, i2, 3) << "(" << dz << ")\n" << endi);
01379 }
01380 }
01381 }
01382 }
|
|
||||||||||||||||
|
Reimplemented from GridforceGrid. Definition at line 66 of file GridForceGrid.inl. References compute_wts(), get_inds(), linear_interpolate(), and Position. 00067 {
00068 int inds[3];
00069 Vector g, dg;
00070
00071 int err = get_inds(pos, inds, dg);
00072 if (err) {
00073 return -1;
00074 }
00075
00076 float wts[8];
00077 float results[4];
00078
00079 compute_wts(wts, dg);
00080 for (int i = 0; i < 4; i++) {
00081 results[i] = linear_interpolate(inds[0], inds[1], inds[2], i, wts);
00082 }
00083
00084 V = results[0];
00085 dV = Vector(results[1], results[2], results[3]) * inv;
00086
00087 return 0;
00088 }
|
|
||||||||||||
|
Definition at line 360 of file GridForceGrid.inl. References DebugM, endi(), Vector::x, Vector::y, and Vector::z. Referenced by compute_VdV(). 00361 {
00362 wts[0] = (1-dg.x) * (1-dg.y) * (1-dg.z);
00363 wts[1] = (1-dg.x) * (1-dg.y) * dg.z;
00364 wts[2] = (1-dg.x) * dg.y * (1-dg.z);
00365 wts[3] = (1-dg.x) * dg.y * dg.z;
00366 wts[4] = dg.x * (1-dg.y) * (1-dg.z);
00367 wts[5] = dg.x * (1-dg.y) * dg.z;
00368 wts[6] = dg.x * dg.y * (1-dg.z);
00369 wts[7] = dg.x * dg.y * dg.z;
00370 DebugM(2, "dg = " << dg << "\n" << endi);
00371 }
|
|
|
Implements GridforceGrid. Definition at line 1431 of file GridForceGrid.C. References DebugM, endi(), and grid. 01432 {
01433 // Creates a flat array of all grid values and puts it in the
01434 // value pointed to by the 'all_gridvals' argument. Returns the
01435 // resulting array size. Caller is responsible for destroying the
01436 // array via 'delete[]'
01437
01438 DebugM(4, "GridforceLiteGrid::get_all_gridvals called\n" << endi);
01439
01440 int sz = size;
01441 DebugM(4, "size = " << sz << "\n" << endi);
01442
01443 float *grid_vals = new float[sz];
01444 int idx = 0;
01445 for (int i = 0; i < size; i++) {
01446 grid_vals[idx++] = grid[i];
01447 }
01448 CmiAssert(idx == sz);
01449
01450 *all_gridvals = grid_vals;
01451
01452 DebugM(4, "GridforceLiteGrid::get_all_gridvals finished\n" << endi);
01453
01454 return sz;
01455 }
|
|
|
Implements GridforceGrid. Definition at line 285 of file GridForceGrid.h. References Position. 00285 { return center; }
|
|
|
Implements GridforceGrid. Definition at line 287 of file GridForceGrid.h. 00287 { return e; }
|
|
||||||||||||||||||||
|
Definition at line 295 of file GridForceGrid.h. References grid, and grid_index(). Referenced by compute_derivative_grids(), initialize(), and linear_interpolate(). 00295 {
00296 return grid[grid_index(i0, i1, i2, i3)];
00297 }
|
|
||||||||||||||||||||
|
Definition at line 298 of file GridForceGrid.h. References grid, and grid_index(). Referenced by compute_derivative_grids(). 00298 {
00299 return double(grid[grid_index(i0, i1, i2, i3)]);
00300 }
|
|
||||||||||||||||
|
Definition at line 338 of file GridForceGrid.inl. References inv, k, and Position. Referenced by compute_VdV(). 00339 {
00340 Vector p = pos - origin;
00341 Vector g;
00342
00343 g = inv * p;
00344
00345 for (int i = 0; i < 3; i++) {
00346 inds[i] = (int)floor(g[i]);
00347 dg[i] = g[i] - inds[i];
00348 }
00349
00350 for (int i = 0; i < 3; i++) {
00351 if (inds[i] < 0 || inds[i] >= k[i]-1) {
00352 return -1; // Outside potential and grid is not continuous
00353 }
00354 }
00355
00356 return 0;
00357 }
|
|
|
Implements GridforceGrid. Definition at line 288 of file GridForceGrid.h. 00288 { return inv; }
|
|
|
Implements GridforceGrid. Definition at line 290 of file GridForceGrid.h. References k. 00290 { return k[0]; }
|
|
|
Implements GridforceGrid. Definition at line 291 of file GridForceGrid.h. References k. 00291 { return k[1]; }
|
|
|
Implements GridforceGrid. Definition at line 292 of file GridForceGrid.h. References k. 00292 { return k[2]; }
|
|
|
Implements GridforceGrid. Definition at line 286 of file GridForceGrid.h. References Position. 00286 { return origin; }
|
|
|
Implements GridforceGrid. Definition at line 289 of file GridForceGrid.h. 00289 { return scale; }
|
|
|
Implements GridforceGrid. Definition at line 293 of file GridForceGrid.h. 00293 { return 1; }
|
|
||||||||||||||||||||
|
Definition at line 319 of file GridForceGrid.h. References dk. Referenced by get_grid(), get_grid_d(), and set_grid(). 00319 {
00320 // 'i3' is an index for the grid itself (0=V, 1=dV/dx, 2=dV/dy, 3=dV/dz)
00321 register int inds[4] = {i0, i1, i2, i3};
00322 return inds[0]*dk[0] + inds[1]*dk[1] + inds[2]*dk[2] + inds[3]*dk[3];
00323 }
|
|
||||||||||||||||
|
Implements GridforceGrid. Definition at line 1305 of file GridForceGrid.C. References center, compute_derivative_grids(), DebugM, dk, e, endi(), filename, GridforceFullMainGrid::get_center(), GridforceFullMainGrid::get_e(), get_grid(), GridforceFullBaseGrid::get_grid(), GridforceFullMainGrid::get_inv(), GridforceFullMainGrid::get_k0(), GridforceFullMainGrid::get_k1(), GridforceFullMainGrid::get_k2(), GridforceFullMainGrid::get_origin(), GridforceFullMainGrid::get_scale(), GridforceFullMainGrid::get_total_grids(), grid, GridforceFullMainGrid::initialize(), inv, k, NAMD_die(), origin, scale, set_grid(), simParams, and size. Referenced by reinitialize(). 01306 {
01307 // cheat and use GridforceFullMainGrid to read the file
01308 GridforceFullMainGrid *tmp_grid = new GridforceFullMainGrid(mygridnum);
01309 tmp_grid->initialize(potfilename, simParams, mgridParams, 1);
01310
01311 if (tmp_grid->get_total_grids() != 1) {
01312 NAMD_die("Cannot use gridforcelite option with multi-resolution grid!");
01313 }
01314
01315 // save file name so that grid can be re-read via Tcl
01316 strcpy(filename, potfilename);
01317
01318 // copy parameters
01319 k[0] = tmp_grid->get_k0();
01320 k[1] = tmp_grid->get_k1();
01321 k[2] = tmp_grid->get_k2();
01322 k[3] = 4; // for V, dV/dx, dV/dy, dV/dz grids
01323 origin = tmp_grid->get_origin();
01324 center = tmp_grid->get_center();
01325 e = tmp_grid->get_e();
01326 inv = tmp_grid->get_inv();
01327 scale = tmp_grid->get_scale();
01328
01329 // calculate rest of parameters
01330 size = k[0] * k[1] * k[2] * k[3];
01331 dk[0] = k[1] * k[2] * k[3];
01332 dk[1] = k[2] * k[3];
01333 dk[2] = k[3];
01334 dk[3] = 1;
01335
01336 // copy the potential grid
01337 delete[] grid;
01338 grid = new float[size];
01339 for (int i0 = 0; i0 < k[0]; i0++) {
01340 for (int i1 = 0; i1 < k[1]; i1++) {
01341 for (int i2 = 0; i2 < k[2]; i2++) {
01342 float V = tmp_grid->get_grid(i0, i1, i2);
01343 set_grid(i0, i1, i2, 0, V);
01344 DebugM(1, "V[" << i0 << "," << i1 << "," << i2 << "] = " << get_grid(i0, i1, i2, 0) << "(" << V << ")\n" << endi);
01345 }
01346 }
01347 }
01348
01349 delete tmp_grid;
01350
01351 compute_derivative_grids();
01352 }
|
|
||||||||||||||||||||||||
|
Definition at line 374 of file GridForceGrid.inl. References DebugM, endi(), and get_grid(). Referenced by compute_VdV(). 00375 {
00376 #ifdef DEBUGM
00377 float vals[8];
00378 vals[0] = get_grid(i0, i1, i2, i3);
00379 vals[1] = get_grid(i0, i1, i2+1, i3);
00380 vals[2] = get_grid(i0, i1+1, i2, i3);
00381 vals[3] = get_grid(i0, i1+1, i2+1, i3);
00382 vals[4] = get_grid(i0+1, i1, i2, i3);
00383 vals[5] = get_grid(i0+1, i1, i2+1, i3);
00384 vals[6] = get_grid(i0+1, i1+1, i2, i3);
00385 vals[7] = get_grid(i0+1, i1+1, i2+1, i3);
00386
00387 switch (i3) {
00388 case 0:
00389 DebugM(2, "V\n" << endi);
00390 break;
00391 case 1:
00392 DebugM(2, "dV/dx\n" << endi);
00393 break;
00394 case 2:
00395 DebugM(2, "dV/dy\n" << endi);
00396 break;
00397 case 3:
00398 DebugM(2, "dV/dz\n" << endi);
00399 break;
00400 }
00401
00402 for (int i = 0; i < 8; i++) {
00403 DebugM(2, "vals[" << i << "] = " << vals[i] << " wts[" << i << "] = " << wts[i] << "\n" << endi);
00404 }
00405 #endif
00406
00407 float result =
00408 wts[0] * get_grid(i0, i1, i2, i3) +
00409 wts[1] * get_grid(i0, i1, i2+1, i3) +
00410 wts[2] * get_grid(i0, i1+1, i2, i3) +
00411 wts[3] * get_grid(i0, i1+1, i2+1, i3) +
00412 wts[4] * get_grid(i0+1, i1, i2, i3) +
00413 wts[5] * get_grid(i0+1, i1, i2+1, i3) +
00414 wts[6] * get_grid(i0+1, i1+1, i2, i3) +
00415 wts[7] * get_grid(i0+1, i1+1, i2+1, i3);
00416
00417 DebugM(2, "result = " << result << "\n" << endi);
00418
00419 return result;
00420 }
|
|
|
Implements GridforceGrid. Definition at line 1391 of file GridForceGrid.C. References center, dk, e, filename, grid, inv, k, origin, MOStream::put(), scale, and size. 01392 {
01393 msg->put(4*sizeof(int), (char*)k);
01394 msg->put(size);
01395 msg->put(4*sizeof(int), (char*)dk);
01396
01397 msg->put(sizeof(Vector), (char*)&origin);
01398 msg->put(sizeof(Vector), (char*)¢er);
01399 msg->put(sizeof(Tensor), (char*)&e);
01400 msg->put(sizeof(Tensor), (char*)&inv);
01401 msg->put(sizeof(Vector), (char*)&scale);
01402
01403 msg->put(129*sizeof(char), (char*)filename);
01404
01405 msg->put(size*sizeof(float), (char*)grid);
01406 }
|
|
||||||||||||
|
Implements GridforceGrid. Definition at line 1385 of file GridForceGrid.C. References filename, initialize(), and simParams. 01386 {
01387 initialize(filename, simParams, mgridParams);
01388 }
|
|
||||||||||||
|
Implements GridforceGrid. Definition at line 1458 of file GridForceGrid.C. References DebugM, endi(), and grid. 01459 {
01460 DebugM(4, "GridforceLiteGrid::set_all_gridvals called\n" << endi);
01461
01462 int sz_calc = size;
01463 CmiAssert(sz == sz_calc);
01464
01465 int idx = 0;
01466 for (int i = 0; i < size; i++) {
01467 grid[i] = all_gridvals[idx++];
01468 }
01469 CmiAssert(idx == sz);
01470
01471 //compute_derivative_grids(); // not needed if we're sending all 4 grids
01472
01473 DebugM(4, "GridforceLiteGrid::set_all_gridvals finished\n" << endi);
01474 }
|
|
||||||||||||||||||||||||
|
Definition at line 301 of file GridForceGrid.h. References grid, and grid_index(). Referenced by compute_derivative_grids(), and initialize(). 00301 {
00302 grid[grid_index(i0, i1, i2, i3)] = V;
00303 }
|
|
|
Implements GridforceGrid. Definition at line 1409 of file GridForceGrid.C. References center, dk, e, filename, MIStream::get(), grid, inv, k, origin, scale, and size. 01410 {
01411 msg->get(4*sizeof(int), (char*)k);
01412 msg->get(size);
01413 msg->get(4*sizeof(int), (char*)dk);
01414
01415 msg->get(sizeof(Vector), (char*)&origin);
01416 msg->get(sizeof(Vector), (char*)¢er);
01417 msg->get(sizeof(Tensor), (char*)&e);
01418 msg->get(sizeof(Tensor), (char*)&inv);
01419 msg->get(sizeof(Vector), (char*)&scale);
01420
01421 msg->get(129*sizeof(char), (char*)filename);
01422
01423 if (size) {
01424 delete[] grid;
01425 grid = new float[size];
01426 msg->get(size*sizeof(float), (char*)grid);
01427 }
01428 }
|
|
|
Definition at line 332 of file GridForceGrid.h. Referenced by initialize(), pack(), and unpack(). |
|
|
Definition at line 329 of file GridForceGrid.h. Referenced by grid_index(), initialize(), pack(), and unpack(). |
|
|
Definition at line 333 of file GridForceGrid.h. Referenced by initialize(), pack(), and unpack(). |
|
|
Definition at line 338 of file GridForceGrid.h. Referenced by initialize(), pack(), reinitialize(), and unpack(). |
|
|
Definition at line 325 of file GridForceGrid.h. Referenced by get_all_gridvals(), get_grid(), get_grid_d(), GridforceLiteGrid(), initialize(), pack(), set_all_gridvals(), set_grid(), and unpack(). |
|
|
Definition at line 334 of file GridForceGrid.h. Referenced by get_inds(), initialize(), pack(), and unpack(). |
|
|
Definition at line 327 of file GridForceGrid.h. Referenced by compute_derivative_grids(), get_inds(), get_k0(), get_k1(), get_k2(), initialize(), pack(), and unpack(). |
|
|
Definition at line 331 of file GridForceGrid.h. Referenced by initialize(), pack(), and unpack(). |
|
|
Definition at line 336 of file GridForceGrid.h. Referenced by initialize(), pack(), and unpack(). |
|
|
Definition at line 328 of file GridForceGrid.h. Referenced by initialize(), pack(), and unpack(). |
1.3.9.1