Ignore:
Timestamp:
Mar 3, 2010, 10:13:19 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
5a40b8, 8758eb, bd506d
Parents:
9f03b2
Message:

singleton class World introduced, contains only cell_size from class molecule.

  • class World is actually code from Till Crueger from his branch StructureRefactoring.
  • has been introduced here in minimalistic form to allow molecule::cell_size to be outsourced to World::cell_size
  • access to cell_size can be obtained from anyhwere by invoking World::get()->cell_size
  • INFO: cell_size was placed in class molecule for the fragmentation procedure where the cell_size had to be individually adapted to each fragment.
  • all appearances have been changed accordingly. Where appropriate we have employed a const pointer onto cell_size.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    r9f03b2 r9565ec  
    6868#include "periodentafel.hpp"
    6969#include "version.h"
     70#include "World.hpp"
    7071
    7172/********************************************* Subsubmenu routine ************************************/
     
    103104        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
    104105        first = new atom;
    105         first->x.AskPosition(mol->cell_size, false);
     106        first->x.AskPosition(World::get()->cell_size, false);
    106107        first->type = periode->AskElement();  // give type
    107108        mol->AddAtom(first);  // add to molecule
     
    114115          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    115116          Log() << Verbose(0) << "Enter reference coordinates." << endl;
    116           x.AskPosition(mol->cell_size, true);
     117          x.AskPosition(World::get()->cell_size, true);
    117118          Log() << Verbose(0) << "Enter relative coordinates." << endl;
    118           first->x.AskPosition(mol->cell_size, false);
     119          first->x.AskPosition(World::get()->cell_size, false);
    119120          first->x.AddVector((const Vector *)&x);
    120121          Log() << Verbose(0) << "\n";
     
    131132          second = mol->AskAtom("Enter atom number: ");
    132133          Log() << Verbose(0) << "Enter relative coordinates." << endl;
    133           first->x.AskPosition(mol->cell_size, false);
     134          first->x.AskPosition(World::get()->cell_size, false);
    134135          for (int i=NDIM;i--;) {
    135136            first->x.x[i] += second->x.x[i];
     
    358359    case 'b': // normal vector of mirror plane
    359360      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    360       n.AskPosition(mol->cell_size,0);
     361      n.AskPosition(World::get()->cell_size,0);
    361362      n.Normalize();
    362363      break;
     
    425426    case 'b': // normal vector of mirror plane
    426427      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    427       n.AskPosition(mol->cell_size,0);
     428      n.AskPosition(World::get()->cell_size,0);
    428429      n.Normalize();
    429430      break;
     
    865866          x.Zero();
    866867          y.Zero();
    867           y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     868          y.x[abs(axis)-1] = World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    868869          for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    869870            x.AddVector(&y); // per factor one cell width further
     
    888889            mol->Translate(&x);
    889890          }
    890           mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     891          World::get()->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    891892        }
    892893      }
     
    945946        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    946947        Log() << Verbose(0) << "Enter translation vector." << endl;
    947         x.AskPosition(mol->cell_size,0);
     948        x.AskPosition(World::get()->cell_size,0);
    948949        mol->Center.AddVector((const Vector *)&x);
    949950     }
     
    10051006        // center at set box dimensions
    10061007        mol->CenterEdge(&center);
    1007         mol->cell_size[0] = center.x[0];
    1008         mol->cell_size[1] = 0;
    1009         mol->cell_size[2] = center.x[1];
    1010         mol->cell_size[3] = 0;
    1011         mol->cell_size[4] = 0;
    1012         mol->cell_size[5] = center.x[2];
     1008        double * const cell_size = World::get()->cell_size;
     1009        cell_size[0] = center.x[0];
     1010        cell_size[1] = 0;
     1011        cell_size[2] = center.x[1];
     1012        cell_size[3] = 0;
     1013        cell_size[4] = 0;
     1014        cell_size[5] = center.x[2];
    10131015        molecules->insert(mol);
    10141016      }
     
    21052107                factor[2] = atof(argv[argptr+2]);
    21062108                mol->Scale((const double ** const)&factor);
     2109                double * const cell_size = World::get()->cell_size;
    21072110                for (int i=0;i<NDIM;i++) {
    21082111                  j += i+1;
    21092112                  x.x[i] = atof(argv[NDIM+i]);
    2110                   mol->cell_size[j]*=factor[i];
     2113                  cell_size[j]*=factor[i];
    21112114                }
    21122115                delete[](factor);
     
    21242127                j = -1;
    21252128                Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2129                double * const cell_size = World::get()->cell_size;
    21262130                for (int i=0;i<6;i++) {
    2127                   mol->cell_size[i] = atof(argv[argptr+i]);
     2131                  cell_size[i] = atof(argv[argptr+i]);
    21282132                }
    21292133                // center
     
    21422146                j = -1;
    21432147                Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2148                double * const cell_size = World::get()->cell_size;
    21442149                for (int i=0;i<6;i++) {
    2145                   mol->cell_size[i] = atof(argv[argptr+i]);
     2150                  cell_size[i] = atof(argv[argptr+i]);
    21462151                }
    21472152                // center
     
    21652170                mol->SetBoxDimension(&x);
    21662171                // translate each coordinate by boundary
     2172                double * const cell_size = World::get()->cell_size;
    21672173                j=-1;
    21682174                for (int i=0;i<NDIM;i++) {
    21692175                  j += i+1;
    21702176                  x.x[i] = atof(argv[argptr+i]);
    2171                   mol->cell_size[j] += x.x[i]*2.;
     2177                  cell_size[j] += x.x[i]*2.;
    21722178                }
    21732179                mol->Translate((const Vector *)&x);
     
    23002306              } else {
    23012307                SaveFlag = true;
     2308                double * const cell_size = World::get()->cell_size;
    23022309                for (int axis = 1; axis <= NDIM; axis++) {
    23032310                  int faktor = atoi(argv[argptr++]);
     
    23262333                    x.Zero();
    23272334                    y.Zero();
    2328                     y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     2335                    y.x[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    23292336                    for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    23302337                      x.AddVector(&y); // per factor one cell width further
     
    23472354                      mol->Translate(&x);
    23482355                    }
    2349                     mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     2356                    cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    23502357                  }
    23512358                }
     
    24162423  if (molecules->ListOfMolecules.size() == 0) {
    24172424    mol = new molecule(periode);
    2418     if (mol->cell_size[0] == 0.) {
     2425    double * const cell_size = World::get()->cell_size;
     2426    if (cell_size[0] == 0.) {
    24192427      Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
    24202428      for (int i=0;i<6;i++) {
    24212429        Log() << Verbose(1) << "Cell size" << i << ": ";
    2422         cin >> mol->cell_size[i];
     2430        cin >> cell_size[i];
    24232431      }
    24242432    }
Note: See TracChangeset for help on using the changeset viewer.